vendredi 19 juin 2020

Laravel collect($array)->sortBy($value)->values() Is showing on screen

I have a little problème on sorting an array according to a value using Laravel, what i did is converting it into a collection with:

$array = collect($array)

Then i sorted it with:

$array = collect($array)->sortBy($sortingValue)

The result here is a collection, so the next step was to get my data as an array back again:

$array = collect($array)->sortBy($sortingValue)->values()

I then wrote this code between semicolons because it's nested in an html code, so got somthing like this:

This is working pretty good, i do have my array sorted according to the parameter i pasted to the function, the problème i have is that this is causing the resulsts to show up on my page in a text format, at the place im executing this code!

Any idea on where this comes from ? im pretty sure it's because of the nested code, but i didn't figure out how to hide that text from my page, and only use the results for the rest of my project.

Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire