php - Make array from jquery serialized string -


i have serialized string jquery:

[{"id":1},  {"id":2,"children":[{"id":3}]},  {"id":4,"children":[{"id":5,"children":[{"id":6,"children":[{"id":7}]}]}]},  {"id":8},{"id":9},{"id":10} ] 

i want pharse in php like:

        $menu = array(                   array( 'name' => 'item 1',  'id' => '1' ,'children' => '0'),                    array( 'name' => 'item 2',  'id' => '2' ,'children' => '0'),                     array( 'name' => 'item 3',  'id' => '3' ,'children' => '2'),                     array( 'name' => 'item 4',  'id' => '4' ,'children' => '0'),                     array( 'name' => 'item 5',  'id' => '5' ,'children' => '4'),                     array( 'name' => 'item 6',  'id' => '6' ,'children' => '5'),                     array( 'name' => 'item 7',  'id' => '7' ,'children' => '6'),                     array( 'name' => 'item 8',  'id' => '8' ,'children' => '0'),                     array( 'name' => 'item 9',  'id' => '9' ,'children' => '0'),                     array( 'name' => 'item 10', 'id' => '10','children' => '0'),                  ); 

(when children == 0, item root category.)

many sugestions. karlis.

check out php's json_decode function, documentation here.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -