0

I want to view the loop of array in blade view, in my view i want print the array items. I tried with this but it doesn't work

               <div class="time-picker-container">
                                <div class="time-picker">
                                    <ul>
                                       @foreach($slots as $key => $slot) 
                                          <li>
                                            <label class="time-picker-toggle-wrapper">
                                                <input type="radio" value="" name="time-picker" />
                                                <span class="time-name">{{ $slot->value }}</span>
                                            </label>
                                        </li>
                                       @endforeach
                                    </ul>                                       
                                </div>
                            </div>

the array:

     array:55 [▼
        0 => array:2 [▼
          "value" => "08:15"
          "time-name" => "08:15 AM"
        ]
        1 => array:2 [▼
          "value" => "08:30"
          "time-name" => "08:30 AM"
        ]
        2 => array:2 [▼
          "value" => "08:45"
          "time-name" => "08:45 AM"
        ]
        3 => array:2 [▼
          "value" => "09:00"
          "time-name" => "09:00 AM"
        ]
1
  • you have an array of arrays, not an array of objects ... how do you access indexes on an array? Commented Jul 27, 2020 at 19:27

1 Answer 1

1

It's an array not object so you need to do {{ $slot['value'] }} not {{ $slot->value }}

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.