0

I have a result array from laravel8 relations. like below

$val = {
         "q_id": 1,
         "q_text": "1111",
         "q_mandatory": 1,
         "q_status": "unpublished",
         "que_logic_relation": [
         {
           "ql_id": 1,
           "ql_quest_id": 1,
           "ql_answer_choice_id": null,
           "ql_succeeding_q_order": 3,

         },
         {
           "ql_id": 4,
           "ql_quest_id": 1,
           "ql_answer_choice_id": null,
           "ql_succeeding_q_order": 3,
       
         }
  
       ]
   }

When I print $val['q_text'] // output 1111 when I print $val['que_logic_relation'] //no result or empty I want to print the data in que_logic_relation seperately. How can I do that?

1
  • This is not a valid php code, you mean your value is json? If so, use $val = json_decode($resultArray,true); Commented Mar 17, 2021 at 9:18

1 Answer 1

1

Issued fixed by adding toArray() to the query result and everything works fine now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.