13

How do I get all of elements with var_dump? I have a huge array but var_dump prints only the first x elemets, and I need all of them to check if my sql is correct.

Cœur
  • 37,241
  • 25
  • 195
  • 267
csaron92
  • 1,035
  • 2
  • 10
  • 20
  • 2
    have you though of `echo '
    ';print_r($array);echo '
    ';` ? Or `foreach($array as $v){var_dump($v);}`?
    – HamZa Apr 29 '13 at 12:00
  • 1
    Possible duplicate of http://stackoverflow.com/q/9998490/ – HamZa Apr 29 '13 at 12:03
  • The other question is very focused on xdebug, where as this just wants an alternative to the default var_dump. – Andrew Apr 02 '19 at 13:09

3 Answers3

36

try

echo '<pre>';
print_r($your_array);
echo '</pre>';

This will not show you type/size of the array elements as var_dump but will show you full array.

Maulik Vora
  • 2,544
  • 5
  • 28
  • 48
3

Use print_r:

<pre>
<?php
    print_r($var); 
?>
</pre>

It's a good way to see your array. The pre element formats it nice and readable.

Richard de Wit
  • 7,102
  • 7
  • 44
  • 54
2

Try print_r e.g.

print_r($myarray);
Dom
  • 7,135
  • 1
  • 11
  • 13