Multi-dimensional array traversal, please give me an answer? ? ?
小帅
小帅 2019-10-08 14:34:22
0
3
1104

$ Result = Array (
Array (
'name' = & gt; 'network',
'phone' = & gt #'The 1st'=>'Program Test 1',
          'The 2nd'=>'Program Test 2',
          ),
          array(
              'name'=>'Network 1',
          'Telephone'=>'12345678911',
 &

小帅
小帅

reply all(2)
海风

The following program can get the array you want to merge no matter how the $result key name is changed:

$arr = [];

foreach ($result as $k => $v){

foreach ($result[$k] as $k1 =>$v2){

if (is_array($result[$k][$k1])) {

foreach ($result[$k][$k1] as $k2 => $v2){

$arr[] = $v2;

}

$temp = [$arr[0] => $arr[1]];

unset ($result[$k][$k1]);

unset ($arr);

%
移动用户-6569216

I can't help you read it because your writing is unclear.

  • reply Thank you, I've got it now, like this: $result2=array(); foreach($result as $k=>$v){ $result2[$k]['name'] = $v['name']; $result2[$k]['Phone'] = $v['Phone']; foreach($v['answer'] as $ak=>$av){ $result2[$k][$av['question_id']] = $av['answer']; } }
    小帅 author 2019-10-08 16:57:23
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template