After submitting the form i am getting the array
$regData = {"student":"699","eposter":"99","exhibitor":"1199","Single-2-nights":"400"};
I need this look like this:
student : 699
eposter : 99
exhibitor : 1199
Single-2-nights : 400
I am writing this like:
<?php
foreach($regData as $key => $value){
$selected .= $key." :". $value."<br/>";
}
?>
Showing error
invalid argument passed to forech
Please help me to fix this error
$regDatalooks more like JSON and as it stands, won't work as an array. If you had quotes round it, then tryjson_decode().$regDatais undefined - where does it come from?$regData = {"student":"699","eposter":"99","exhibitor":"1199","Single-2-nights":"400"};isn't valid PHP. This can't be your real code. Please clarify. Is it actually a string like$regData = '{"student":"699","eposter":"99","exhibitor":"1199","Single-2-nights":"400"}';, perhaps? That would be valid. Then, as the first comment above says, you could decode it into an array / object and then use it easily in a loop.