2023-01-14 320
1、array_filter() 函数可以用回调函数来过滤数组中的元素,将数组元素传递给回调函数进行处理。
2、如果回调函数返回true,则把输入数组中的当前键值返回给结果数组。
(数组键名保持不变)
<?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);
?>
知识点扩展:
用array_merge和加号来何必这两数组
<?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>
?>
以上所述是小编给大家介绍的php提取数字拼接数组的具体操作,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!
原文链接:https://77isp.com/post/25535.html
=========================================
https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。
数据库技术 2022-03-28
网站技术 2022-11-26
网站技术 2023-01-07
网站技术 2022-11-17
Windows相关 2022-02-23
网站技术 2023-01-14
Windows相关 2022-02-16
Windows相关 2022-02-16
Linux相关 2022-02-27
数据库技术 2022-02-20
抠敌 2023年10月23日
嚼餐 2023年10月23日
男忌 2023年10月22日
瓮仆 2023年10月22日
簿偌 2023年10月22日
扫码二维码
获取最新动态