I request an API and send a JSON response, which I then change to an array. This part works fine, but the API sends the information in a rather unfriendly format.
I will insert the part that I'm having problems with. Essentially, I am trying to change each similar key into my own array.
Array ( [name] => Name [address] => 123 Street Rd [products[0][product_id]] => 1 [products[0][price]] => 12.00 [products[0][name]] => Product Name [products[0][product_qty]] => 1 [products[1][product_id]] => 2 [products[1][price]] => 3.00 [products[1][name]] => Product Name [products[1][product_qty]] => 1 [systemNotes[0]] => Note 1 [systemNotes[1]] => Note 2 )
Now what I would like to do is do it something like this:
Array ( [name] => Name [address] => 123 Street Rd [product] => Array ( [0] => Array ( [product_id] => 1 [price] => 12.00 [name] => Product Name [product_qty] => 1 ) [1] => Array ( [product_id] => 2 [price] => 3.00 [name] => Product Name [product_qty] => 1 ) [systemNotes] => Array ( [0] => Note 1 [1] => Note 2 ) )
Is there any practical way to do this?
Thanks!
source share