samedi 27 avril 2019

Obtain all keys x from an array of objects (laravel)

The database is storing an array of objects that look like this:

[
{"id":92,"product_id":8966,"extra_type":"Extras","extra_name":"Olives"},

{"id":93,"product_id":8966,"extra_type":"Extras","extra_name":"Ketchup"},

{"id":92,"product_id":8966,"extra_type":"Extras","extra_name":"Olives"}
]

The code below (from the Laravel blade) returns the array of objects.

@foreach($item->orderedProducts as $op)
<tr>
     <td>
         <span></span><br>
     </td>
</tr>
@endforeach

What I am trying to achieve is obtain all the values of (for example) "extra_name".

The desired output should be:

Olives Ketchup Olives



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2XN0xHR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire