Here is an array which contains Integer and NULL values. I want to exclude these two things from the array and print the rest.
I am using array_filter() using callback. But there is something wrong with it. I could not figure out the real issue for hours.
Please help me figure out.
Here is the code.
<?php
function remove_elem($var) {
return($var & is_numeric($var[0]) & ' ');
}
?>
<?php
$a1=array(1,'Programming','Design','Marketing',' ',' ');
print_r(array_filter($a1,"remove_elem"));
?>
Thank You!
Your remove_ele function has issue.
Use this it will work fine.
function remove_elem($var) {
return $var != " " && !is_numeric($var);
}
$a1=array(1,'Programming','Design','Marketing',' ',' ');
print_r(array_filter($a1,"remove_elem"));