codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $products = array( 'CATEGORY' => array( 0 => 'book', 1 => 'book', 2 => 'desk', ), /* FYI: Other keys have been removed for conciseness */ 'DESCRIPTION' => array( 0 => 'Bar', 1 => 'sdfadasfdasfas', 2 => 'Barrrr', ), ); $newProducts = array(); $newProducts['CATEGORY'] = array(); foreach ($products['CATEGORY'] as $id =>$cat) { $newProducts['CATEGORY'][$cat] []= array('DESCRIPTION' => $products['DESCRIPTION'][$id]); } var_dump($newProducts); ?>
Private
[
?
]
Run code
Submit