1、array_filter() 函數(shù)可以用回調(diào)函數(shù)來過濾數(shù)組中的元素,將數(shù)組元素傳遞給回調(diào)函數(shù)進(jìn)行處理。
2、如果回調(diào)函數(shù)返回true,則把輸入數(shù)組中的當(dāng)前鍵值返回給結(jié)果數(shù)組。
(數(shù)組鍵名保持不變)
實例
?php
$array = array("php", 11, '', 12, "腳本之家",13,"green",2021,"mysql","14",15);
function filter_number($value){
if(is_numeric($value)){
return TRUE;
}
}
$result=array_filter($array,"filter_number");
var_dump($result);
?>
知識點(diǎn)擴(kuò)展:
用array_merge和加號來何必這兩數(shù)組
?php
print_r($r+e); // 輸出span style="font-family: Simsun;font-size:16px; ">Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 ) /span>
print "br />";
print_r(array_merge($r,$e)); // 輸出span style="font-family: Simsun;font-size:16px; ">Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 )/span>
?>
到此這篇關(guān)于php提取數(shù)字拼接數(shù)組的具體操作的文章就介紹到這了,更多相關(guān)php如何提取數(shù)字拼接數(shù)組內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- php中的四舍五入函數(shù)代碼(floor函數(shù)、ceil函數(shù)、round與intval)
- PHP取整函數(shù):ceil,floor,round,intval的區(qū)別詳細(xì)解析
- php fopen()函數(shù)案例詳解
- PHP檢查空值的方法總結(jié)
- php floor()函數(shù)案例詳解