javascript - How to access value from json decode array
Get the solution ↓↓↓Solution:
Try this:
$test=json_decode($tableData);
foreach($test as $arr) {
echo $arr->IngredientName."<br />";
}
Answer
Solution:
The result of decoding a JSON is an array of arrays. You can iterate through them the following way:
$test=json_decode($tableData,TRUE);
foreach($test as $ingredient) {
echo $ingredient['IngredientName'] . '<br />';
}
Answer
Solution:
This might be a working approach:
<?php
$encoded = '[{"IngredientName":"Sunflower","Quantity":"6","Free_Quantity":"0","Rate":"6"},{"IngredientName":"ganapathi","Quantity":"6","Free_Quantity":"0","Rate":"6"}]';
$decoded = json_decode($encoded);
foreach ($decoded as $object) {
var_dump($object->IngredientName);
}
The obvious output is:
string(9) "Sunflower"
string(9) "ganapathi"
Answer
Solution:
Try something like this
foreach($tableData as $value){
echo json_decode($value['IngredientName']);
}
Answer
Solution:
$array=json_decode($tableData,TRUE);
foreach ($array as $key => $value) {
echo $value['IngredientName'] . '<br />';
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: http failure during parsing for
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.