2016-04-15 28 views
0

我正在使用dump($value)函數。我有一個有很多條目的關聯數組。我需要立即看到這些值,而不必在傾倒時單擊擴展按鈕。我可以使用var_dump()立即看到它,但我更喜歡使用dump,因爲它是現代和互動的。下面是轉儲功能的快照:作爲擴展數組在laravel中轉儲返回值

enter image description here

+1

使用其他格式化工具可以總是幫助 - http://stackoverflow.com/questions/2141585/a-more-pretty-informative-var-dump-alternative- in-php –

+2

你可以設計一些東西,使它在這個線程的默認情況下崩潰https://laracasts.com/discuss/channels/general-discussion/the-new-dd-in-laravel-5-is-kind- of-shitty?page = 1或者只是使用ol''echo'

', print_r($value, 1), '
';死;' – Ghost

回答

1

這裏有一個快速格式化工具,沒有必要使用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); 

這裏的示例輸出的屏幕截圖,以及。 (搞清楚是什麼數據,獎勵積分) screenshot of output

+1

謝謝。這是我需要的。雖然我想要轉儲的設計方式,但我總是可以添加簡單的樣式以使其更漂亮。 – KristCont