0

I know this is possible but I've tried to search from the net but I've never found an answer so if anyone who knows how to push data to array from @foreach using Laravel View please help me. Thanks in advance

Here is the code

@foreach ($fields as $key => $rel)

 {{ $arrayData = array(

    'field_type' =>'$rel->field_type'
 )}}

@endforeach

The error I've receiving is

ErrorException in helpers.php line 519: htmlspecialchars() expects parameter 1 to be string, array given (View: C:\xampp\htdocs\fields.blade.php)

1 Answer 1

1

Remove quote from $rel->field_type

@foreach ($fields as $key => $rel)

 {{ $arrayData = array(

    'field_type' =>$rel->field_type
 )}}

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

6 Comments

Error sir a Use of undefined constant field_type - assumed 'field_type' (View: C:\xampp\htdocs\papers\resources\views\admin\fields.blade.php)
can you print print_r($fields) before foreach loop and update question.i think field_type not there in array
{ "field_id": 82, "field_name": "field_name", "field_slug": "field_slug", "field_label": "field_label", "field_type": "text", }
@Paul.can you post all data of printed print_r($fields) becasue that data is not array
ooops my fault lemme send the image for the output
|

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.