In this tutorial learn How to convert JSON string format to array format in php, here more with the example.
Convert JSON string to array using php
echo "json => ". $str='{"data":[{"id":"2","qty":"10","size":"1,2,3"}, {"id":"3","qty":"4","size":"1,2,3"}]}';
$data = json_decode($str, TRUE);
echo "<pre>";
print_r($data);
foreach ($data as $key => $value) {
echo "Convert into string <br>";
foreach ($value as $key => $values) {
foreach ($values as $key => $v) {
echo $key."==>" .$v;
}
echo "<br>";
}
}
Convert JSON string to array using php
$data = json_decode($str, TRUE);
echo "<pre>";
print_r($data);
foreach ($data as $key => $value) {
echo "Convert into string <br>";
foreach ($value as $key => $values) {
foreach ($values as $key => $v) {
echo $key."==>" .$v;
}
echo "<br>";
}
}
No comments:
Post a Comment