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
Post a Comment