Following below is the json data which i am sending to php controller by using ajax
[
{
"First":"A,b"
},
{
"Second":""
},
{
"Third":""
},
{
"Fourth":""
},
{
"Fifth":""
},
{
"Sixth":""
},
{
"Seventh":""
},
{
"Eight":""
},
{
"Ninth":""
},
{
"Tenth":""
}
]
how can i read values and stored it in php variable or use loop with above json string
You need to decode your json string by using json_decode()
than you can use foreach()
loop.
print_r(json_decode($jsonString,TRUE)); // will return response in an array
print_r(json_decode($jsonString)); // will return response in an object
And you can read the data as:
$decoded = json_decode($jsonString,TRUE);
foreach( $decoded as $key => $value ){
// print values
// print key
}
Try to use PHP built in function json_decode
http://www.php.net/manual/en/function.json-decode.php
Then access it like an array
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.