php下幾個(gè)常用的去空、分組、調(diào)試數(shù)組函數(shù)
更新時(shí)間:2009年02月22日 02:35:09 作者:
dump() 把數(shù)組以數(shù)組格式數(shù)組,有益于調(diào)試 array_chunk() php默認(rèn)函數(shù) 作用是把函數(shù)平均分組
dump() 把數(shù)組以數(shù)組格式數(shù)組,有益于調(diào)試
function dump($vars, $label = '', $return = false){
if (ini_get('html_errors')) {
$content = "<pre>\n";
if ($label != '') {
$content .= "<strong>{$label} :</strong>\n";
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= "\n</pre>\n";
} else {
$content = $label . " :\n" . print_r($vars, true);
}
if ($return) { return $content; }
echo $content;
return null;
}
array_remove_empty()去除數(shù)組中為空的元素
function array_remove_empty(& $arr, $trim = true){
foreach ($arr as $key => $value) {
if (is_array($value)) {
array_remove_empty($arr[$key]);
} else {
$value = trim($value);
if ($value == '') {
unset($arr[$key]);
} elseif ($trim) {
$arr[$key] = $value;
}
}
}
}
array_chunk() php默認(rèn)函數(shù) 作用是把函數(shù)平均分組
function dump($vars, $label = '', $return = false){
if (ini_get('html_errors')) {
$content = "<pre>\n";
if ($label != '') {
$content .= "<strong>{$label} :</strong>\n";
}
$content .= htmlspecialchars(print_r($vars, true));
$content .= "\n</pre>\n";
} else {
$content = $label . " :\n" . print_r($vars, true);
}
if ($return) { return $content; }
echo $content;
return null;
}
array_remove_empty()去除數(shù)組中為空的元素
function array_remove_empty(& $arr, $trim = true){
foreach ($arr as $key => $value) {
if (is_array($value)) {
array_remove_empty($arr[$key]);
} else {
$value = trim($value);
if ($value == '') {
unset($arr[$key]);
} elseif ($trim) {
$arr[$key] = $value;
}
}
}
}
array_chunk() php默認(rèn)函數(shù) 作用是把函數(shù)平均分組
您可能感興趣的文章:
- PHP數(shù)字前補(bǔ)0的自帶函數(shù)sprintf 和number_format的用法(詳解)
- PHP常用函數(shù)總結(jié)(180多個(gè))
- PHP下使用mysqli的函數(shù)連接mysql出現(xiàn)warning: mysqli::real_connect(): (hy000/1040): ...
- PHP中鮮為人知的10個(gè)函數(shù)
- php用header函數(shù)實(shí)現(xiàn)301跳轉(zhuǎn)代碼實(shí)例
- PHP header()函數(shù)使用詳細(xì)(301、404等錯(cuò)誤設(shè)置)
- php set_time_limit(0) 設(shè)置程序執(zhí)行時(shí)間的函數(shù)
- PHP使用trim函數(shù)去除字符串左右空格及特殊字符實(shí)例
- PHP判斷是否為空的幾個(gè)函數(shù)對(duì)比
- php中使用array_filter()函數(shù)過(guò)濾空數(shù)組的實(shí)現(xiàn)代碼
- php empty函數(shù)判斷mysql表單是否為空
- PHP 清除HTML代碼、空格、回車(chē)換行符的函數(shù)
- php通過(guò)各種函數(shù)判斷0和空
相關(guān)文章
laravel5實(shí)現(xiàn)微信第三方登錄功能
這篇文章主要介紹了laravel5實(shí)現(xiàn)微信第三方登錄功能,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-12-12
PHP實(shí)現(xiàn)微信提現(xiàn)功能(微信商城)
這篇文章主要介紹了PHP實(shí)現(xiàn)微信提現(xiàn)功能,此類(lèi)功能在微信商城中經(jīng)常會(huì)用到,今天小編通過(guò)實(shí)例代碼給大家講解,需要的朋友可以參考下2019-11-11
PHP+MySQL實(shí)現(xiàn)對(duì)一段時(shí)間內(nèi)每天數(shù)據(jù)統(tǒng)計(jì)優(yōu)化操作實(shí)例
這篇文章主要介紹了PHP+MySQL實(shí)現(xiàn)對(duì)一段時(shí)間內(nèi)每天數(shù)據(jù)統(tǒng)計(jì)優(yōu)化操作,結(jié)合具體實(shí)例形式分析了php針對(duì)mysql查詢(xún)統(tǒng)計(jì)相關(guān)優(yōu)化操作技巧,需要的朋友可以參考下2018-03-03
laravel使用Faker數(shù)據(jù)填充的實(shí)現(xiàn)方法
這篇文章主要給大家介紹了關(guān)于laravel使用Faker數(shù)據(jù)填充的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用laravel具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
thinkPHP+mysql+ajax實(shí)現(xiàn)的仿百度一下即時(shí)搜索效果詳解
這篇文章主要介紹了thinkPHP+mysql+ajax實(shí)現(xiàn)的仿百度一下即時(shí)搜索效果,結(jié)合完整實(shí)例形式詳細(xì)分析了thinkPHP+mysql+ajax實(shí)現(xiàn)的仿百度一下即時(shí)搜索效果具體數(shù)據(jù)表、控制器、前臺(tái)視圖與樣式相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2019-07-07
Laravel-添加后臺(tái)模板AdminLte的實(shí)現(xiàn)方法
今天小編就為大家分享一篇Laravel-添加后臺(tái)模板AdminLte的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10
php+memcache實(shí)現(xiàn)的網(wǎng)站在線人數(shù)統(tǒng)計(jì)代碼
這篇文章主要介紹了php+memcache實(shí)現(xiàn)的網(wǎng)站在線人數(shù)統(tǒng)計(jì)代碼,代碼例子簡(jiǎn)潔實(shí)用,需要的朋友可以參考下2014-07-07

