php - multidimensional array, transpositional values and merged result -


i have , array $aarg these values

array ( 0 => 'reviewed_entity', 1 => 'kiosk', ) array ( 0 => 'tripadvisor', 1 => 'tripadvisor2', ) array ( 0 => 'google', 1 => 'google2', ) array ( 0 => 'yahoo', 1 => 'yahoo2', ) 

i need make appear below.

array ('kiosk'  =>  array ( 'tripadvisor' => 'tripadvisor2','google' => 'google2','yahoo' => 'yahoo2',)); 
  • please note few things kiosk value of [1] of first array. , it's parent array'
  • other arrays have values of [0] transpose key [1]
  • all arrays have been merged one.

thank guys have had sleepless nights trying final merge result, please share me fastest way desired results

your input array doesn't seems correct. thought following..

<?php $aarg = array( array ( 0 => 'reviewed_entity', 1 => 'kiosk', ), array ( 0 => 'tripadvisor', 1 => 'tripadvisor2', ), array ( 0 => 'google', 1 => 'google2', ), array ( 0 => 'yahoo', 1 => 'yahoo2', ));   $newarr = array($aarg[0][1] => array()); $i = 0; foreach($aarg $arr) {   if($i) {     $newarr[$aarg[0][1]][$arr[0]] = $arr[1];   }   $i ++; }  var_export($newarr); 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -