Transform PHP array -
i have php array i'm trying transform different format, way can think lot longer seems should need.
example data:
array ( [0] => array (     [type] =>     [value] => 1     ) [1] => array (     [type] =>     [value] => 2     ) [2] => array (     [type] =>     [value] => 3     ) [3] => array (     [type] => b     [value] => 1     ) [4] => array (     [type] => b     [value] => 4     ) [5] => array (     [type] => f     [value] => 2     ) )    into:
array ( 'a' => array(1,2,3), 'b' => array(1,4), 'f' => array(2) )      
foreach ($array $element)      $newarray[$element["type"]][] = $element["value"];        
Comments
Post a Comment