php - Proper nested array to JSON formatting for API curl post

Solution:
The elements that show brackets should be arrays of arrays, which makes sense given that "order_items" and "print_locations" can have multiple entries. You will need to nest the arrays a little deeper at those levels, like this:
'order_items'=> array (
array( // one order item
'name'=>"Dale Blaney 2016 Design",
'quantity'=>"1",
'code'=>"1081389-GSS-FB-2XL-BK",
'variation_list'=> array (
'size'=>"2XL",
'color'=>"Black",
'style'=>"5000"
),
'print_locations'=> array (
array( // one print location
'location_name'=>"Full Front",
'location_art'=>"http://somedomain.com/link_to_your_artwork.png",
'location_preview'=>"http://somedomain.com/link_to_your_preview.png"
)
)
)
)
When you get to the actual implementation you will likely need to use some kind of loop on these fields to insert all the "order_items" and "print_locations"
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: php undefined array key
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.