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

Popular posts from this blog

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

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -