手册查询array_filter()的使用细节时,看到了:If no callback is supplied, all entries of input equal to FALSE (see converting to boolean) will be removed. 如果没有给出回调函数,所有的等于 FALSE 的元素将会被移除掉!

刚好可以用来移除数组中的空元素!

使用:$arr = array_filter($arr);

过滤数组中的空数组array_filter()

 

 

<?php
$arr=array(1,2,3,null,'',false);
$new=array_filter($arr);
echo '<pre>';
print_r($new);
echo '<pre>';

 结果:

 过滤数组中的空数组array_filter()

 



原文:https://blog.csdn.net/guaiguaiknl/article/details/60961782

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-21
  • 2021-05-30
  • 2021-09-07
  • 2022-02-06
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-28
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-10
相关资源
相似解决方案