PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, November 15, 2022

[FIXED] How can i use the decoded json data when the first index data is very large in laravel

 November 15, 2022     laravel, laravel-6.2, php, php-7.2     No comments   

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.

enter image description here

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing