Skip to content

PHP/JS Array Filtering

dhtmldhtml Posts: 27

Filter array A [PHP]:
$array = [0, 1, 2, "", 3, 3,null];
$filtered = $array.filter((el)=>el != null && el!=='');

Filter Array B [JavaScript]:
$array = [0, 1, 2, "", 3, 3,null];
$filtered = array_filter($array, fn($el) => $el!==null && $el !== '');

Sign In or Register to comment.