0

I am trying to get array value in BLADE file. My array is shown below but I am not able to get value inside array.

I have get [student_levels]=> [level] Data

laravel Code

foreach($items as $item)
{
    echo $item['student_levels']['level'];
}

$items is Array

Array
(
    [0] => Array
        (
            [_id] => 5c1e4295b0dace71ec62e325
            [email] => [email protected]
            [franchisecode] => MELHH
            [title] => Mr
            [firstname] => dhaval s
            [lastname] => patel
            [gender] => Male
            [age] => 16-18
            [phone] => 9601354880
            [address] => rajkot
            [city] => Ahmedabad
            [country] => India
            [tempcode] => hUmoEF
            [studentid] => HTNKLF
            [updated_at] => 2019-11-21 13:32:31
            [created_at] => 2018-12-22 19:26:37
            [student_status] => eda
            [student_levels] => Array
                (
                    [_id] => 5c8b11d2b0dace2f9a044d86
                    [student_id] => HTNKLF
                    [teacher_id] => 5c1e1ab5b0dace716e429654
                    [level_name] => recomended_level
                    [level] => Level 1
                    [comments] => hhbhhhh
                    [exam_type] => eda
                    [student_course] => 
                    [updated_at] => 2019-03-15 08:15:38
                    [created_at] => 2019-03-15 08:15:38
                )

        )

2 Answers 2

2

You have an array inside an array..so you can use foreach loop as

 @foreach($items as $item)
   {{$item['student_levels']['level']}}
 @endforeach

Or directly

{{$items[0]['student_levels']['level']}}
Sign up to request clarification or add additional context in comments.

1 Comment

Please add some explanation to your code such that others can learn from it
0

It seems your array is returning an array of students, you have an extra level in your array. So to fetch the first student level, you need to use the following code:

echo $item[0]['student_levels']['level'];

Maybe the code that fetches this data could be optimized to only fetch a single student, could you post this code?

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.