Array
(
[0] => Array
(
[name] => Холопова Анастасия
[num_meet1] => 4
)
[1] => Array
(
[name] => Погарченкова Мария
[num_meet1] => 2
)
[2] => Array
(
[name] => Индутова Валерия
[num_meet1] => 1
)
[3] => Array
(
[name] => Валерьянова Саша
[num_meet2] => 1
)
[4] => Array
(
[name] => Валерьянова Саша
[num_meet3] => 1
)
[5] => Array
(
[name] => Холопова Анастасия
[num_meet4] => 1
)
)
[0] => Array (
[name] => Холопова Анастасия
[num_meet1] => 4
[num_meet2] =>
[num_meet3] =>
[num_meet4] => 1
[num_meet5] =>
[num_meet6] =>
)
[1] => Array
(
[name] => Валерьянова Саша
[num_meet1] =>
[num_meet2] => 1
[num_meet3] => 1
[num_meet4] =>
[num_meet5] =>
[num_meet6] =>
)
)
/**
*
* Input array consists of elements as in example
* <code>
* Array
* (
* [0] => Array
* (
* [name] => Холопова Анастасия
* [num_meet1] => 4
* )
*
* [1] => Array
* (
* [name] => Погарченкова Мария
* [num_meet1] => 2
* )
*
* [2] => Array
* (
* [name] => Индутова Валерия
* [num_meet1] => 1
* )
*
* [3] => Array
* (
* [name] => Валерьянова Саша
* [num_meet2] => 1
* )
*
* [4] => Array
* (
* [name] => Валерьянова Саша
* [num_meet3] => 1
* )
*
* [5] => Array
* (
* [name] => Холопова Анастасия
* [num_meet4] => 1
* )
*
* )
* </code>
*
* @param array $array
*
* @return array
*/
function alterArray(array $array){
$newArray = [];
foreach($array as $subarray)
{
if(isset($subarray['name']))
{
$lastElementOfArray = array_slice($subarray, 1, 1);
reset($lastElementOfArray);
$newArray[ $subarray['name'] ][ key($lastElementOfArray) ] = current($lastElementOfArray);
}
}
return $newArray;
}
array_combine(
array_map($array, function($a) {return $a['name'];}),
$array
);