Home  >  Article  >  Backend Development  >  php array_filter removes empty character elements in array_PHP tutorial

php array_filter removes empty character elements in array_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:23:16835browse

Remove empty character elements in the array

Copy code The code is as follows:

$str1_array=array ('Script Home','','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] => Script Home
[2] => http://www.jb51.net
[4] => 1654
)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324568.htmlTechArticleRemove the empty character elements in the array and copy the code as follows: ?php $str1_array=array('Script Home' ,'','http://www.jb51.net','','1654',''); $str1_array=array_filter($str1_array); pri...
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