// The array_diff() function compares the values of two (or more) arrays, and returns the differences.
// Input: nums = [0,1,2,2,3,0,4,2], val = 2
// output: nums = [0,1,3,0,4]
function removeElement($nums, $val) {
return array_diff($nums, [$val]);
}
print_r(removeElement([0,1,2,2,3,0,4,2], 2);
// runtime 7ms