4

I am using dump($value) function. I have an associative array with lots of entries in it. I need to see the values right away without having to click the expansion button when dumped. I can use var_dump() to see it right away but I like it more using dump because it is modern and interactive. Below is the snapshot of dump function:

enter image description here

kriscondev
  • 765
  • 7
  • 21
  • 1
    Using another formatting tool could always help - http://stackoverflow.com/questions/2141585/a-more-pretty-informative-var-dump-alternative-in-php – James Paterson Apr 15 '16 at 00:37
  • 2
    you could devise something that will make it collapse in default in this thread https://laracasts.com/discuss/channels/general-discussion/the-new-dd-in-laravel-5-is-kind-of-shitty?page=1 or just use the ol' `echo '
    ', print_r($value, 1), '
    '; die;`
    – Kevin Apr 15 '16 at 00:37

5 Answers5

21

the simple tip is: CTRL+click.

Viet Ngo
  • 231
  • 2
  • 2
3

Here's the JavaScript you can put after the dump():

var compacted = document.querySelectorAll('.sf-dump-compact');

for (var i = 0; i < compacted.length; i++) {
  compacted[i].className = 'sf-dump-expanded';
}

Credits go to Curtis Blackwell

Shone Tow
  • 497
  • 4
  • 14
2

you can use

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

or more easy way is just

var_dump($results);
Somwang Souksavatd
  • 4,947
  • 32
  • 30
1

Here's a quick format tool, no need to use laravel: (Source)

$pretty = function($v='',$c="&nbsp;&nbsp;&nbsp;&nbsp;",$in=-1,$k=null)use(&$pretty){$r='';if(in_array(gettype($v),array('object','array'))){$r.=($in!=-1?str_repeat($c,$in):'').(is_null($k)?'':"$k: ").'<br>';foreach($v as $sk=>$vl){$r.=$pretty($vl,$c,$in+1,$sk).'<br>';}}else{$r.=($in!=-1?str_repeat($c,$in):'').(is_null($k)?'':"$k: ").(is_null($v)?'&lt;NULL&gt;':"<strong>$v</strong>");}return$r;};

echo $pretty($array);

Here's a screenshot of sample output, as well. (Bonus points for figuring out what the data is) screenshot of output

Community
  • 1
  • 1
James Paterson
  • 2,652
  • 3
  • 27
  • 40
  • 1
    thank you. this is what I need. Though I want the way dump is designed, but I can always add simple styles to make it prettier. – kriscondev Apr 15 '16 at 00:54
1

Inject this script in Browser with help of the temper monkey chrome extension and add the script for that web page where you want to do that...

let all_dumps = document.getElementsByClassName('sf-dump-note');
for(let i = 1 ; i < all_dumps.length ; i ++ ) {
    all_dumps[i].click();
}
Amritesh
  • 87
  • 1
  • 7