hi when i have array like this: PHP: ["one", "two", "three"] how can i remove "two" when i dont know key? or PHP: $array = [1, 2, 3, 4,5];$var = rand(1, 5); and i need to remove $var EDIT: maybe array_search() ---> no it wont work
You can use differences PHP: <?php$array = array("one", "two", "three");$array = array_diff($array, array('two'));print_r(array_values($array));?> In my example above $array would now be: array("one", "three");
All arrays have a key, if you don't set it's automatically set as a number. In this case: PHP: "one" => [0]"two" => [1]"three" => [2]