Home  >  Article  >  Backend Development  >  intentfilter php array_filter removes empty character elements in the array

intentfilter php array_filter removes empty character elements in the array

WBOY
WBOYOriginal
2016-07-29 08:47:14914browse

Remove empty character elements in the array

Copy the code The code is as follows:


$str1_array=array('this site','','http://www.jb51.net' ,'','1654','');
$str1_array=array_filter($str1_array);
print_r($str1_array);
?>


Display results:

Copy code The code is as follows:


Array
(
[0] => This site
[2] => http://www.jb51.net
[4] => 1654
)

The above introduces intentfilter php array_filter to remove empty character elements in the array, including the content of intentfilter. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn