Issue
After decoding the json data i am getting these value and i want to use these separately to show it in the textbox for updating these data. but i cannot get any way to do it.
i am encoding it as below in the controller
$data = json_encode(array(
$request->question1 => $request->answer1,
$request->question2 => $request->answer2,
$request->question3 => $request->answer3,
$request->question4 => $request->answer4
));
@php $data = json_decode($contact_us->key_value); @endphp
i want to do it in the view to show it in the textbox.
Solution
foreach(json_decode($data) as $x) {
echo $x;
}
Access the individual properties by using a foreach
To both key and value
foreach(json_decode($data) as $key => $value) {
echo $key . ' ' . $value;
}
Answered By - Devin Gray Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.