Skip to content
Advertisement

How to display a readable array – Laravel

After I write:

JavaScript

And after I refresh the browser I get an unreadable array. Is there a way to get that array in a readable format?

Advertisement

Answer

dd() dumps the variable and ends the execution of the script (1), so surrounding it with <pre> tags will leave it broken. Just use good ol’ var_dump() (or print_r() if you know it’s an array)

JavaScript

Update:

I think you could format down what’s shown by having Laravel convert the model object to array:

JavaScript

(1) For the record, this is the implementation of dd():

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement