If you are trying to exclude few elements from an array which are common to another array’s elements, then “array_diff” is the perfect function for you. Use as below:
1
2
3
4
| $myarray1 = array (1,2,3,4,-1,-2); $myarray2 = array (-1,-2); $filtered_array = array_diff ( $myarray1 , $myarray2 ); print_r( $filtered_array ); |
No comments:
Post a Comment