php - Manipulate array foreach -
i have array 1 , should 2
does have idea / solution?
do need foreach or loop?
1.
array ( [0] => array ( [category_id] => 5 [category] => pages )
)
must be:
array ( [0] => array ( [5] => pages )
)
i have doent work...
for($x = 0; $x <= $counter; $x++){ foreach ($categories[$x] $key => $value){ echo $key.' '. $value.'<br>'; } $test[$x]['category_id'] .= $categories[$x]['category']; }
thanks help!
code:
<?php $arr = array( array( 'category_id' => 5 , 'category' => 'pages', ), ); $new = array(); foreach ($arr $item) { $new[] = array( $item['category_id'] => $item['category'] ); } print_r($new);
result:
array ( [0] => array ( [5] => pages ) )
Comments
Post a Comment