For this particular problem I need to send 2 serialized forms to my server at once plus a few values in JSON format. The structure of my JSON object will always look like the below:
"{
"startDate":"2015-07-20",
"planName":"MySecondAttempt",
"clientId":"5",
"client_update_form":"client_id=5&squat_max=300&deadlift_max=100&bench_max=275",
"user_id":3,
"workoutDaysArray":[
"workoutDayName=Legs©Underway=0&date=July+21&workoutId=4&setInstruction1=2&repInstruction1=4&weightInstruction1=6&restInstruction1=8&workoutId2=&setInstruction2=&repInstruction2=&weightInstruction2=&restInstruction2=",
"workoutDayName=Arms©Underway=0&date=July+23&workoutId=7&setInstruction1=1&repInstruction1=2&weightInstruction1=3&restInstruction1=4&workoutId2=2&setInstruction2=2&repInstruction2=4&weightInstruction2=6&restInstruction2=8&workoutId3=3&setInstruction3=2&repInstruction3=4&weightInstruction3=6&restInstruction3=8&workoutId4=&setInstruction4=&repInstruction4=&weightInstruction4=&restInstruction4="
]}"
I then access the object with the below:
$input = json_decode(file_get_contents('php://input'), true);
$trainerId = $input['user_id'];
$workoutDaysArray = $input['workoutDaysArray'];
$startDate = $input['startDate'];
$planName = $input['planName'];
$clientUpdateForm = $input['client_update_form'];
So now the variable $workoutDaysArray, for instance hold the value of a serialized form represented as a string. I'm hoping there's a way to access the key value pairs in that serialized form without having to parse the string manually or rewrite a lot of javascript.
I was hoping something similar to this would work, but I think I may be off here:
foreach($workoutDaysArray as $key=>$value){
//some code
}
Any thoughts?
Thanks!!