Category Archives: Useful PHP Functions

Remove element from Array

Remove element from array array_diff($arr1, $arr2) array_diff_key($arr1, $arr2) <?php $a1 = array(‘a’=>1, ‘b’=>2, ‘c’=>3, ‘d’=>4); $a2 = array(‘a’=>”, ‘c’=>”); $a3 = array(1, 2, 4); $result = array_diff_key($a1, $a2); print_r($result); $result = array_diff($a1, $a3); print_r($result); ?> Output Array ( [b] => … Continue reading

Posted in Array Helper Functions, Useful PHP Functions | 2 Comments