You can use the array_search() function to first search the given value inside the array and get its corresponding key, and later remove the element using that key with unset() function.
Please note that, if the value is found more than once, only the first matching key is returned.
Let's take a look at an example to understand how it actually works:
Use the
array_search()FunctionYou can use the
array_search()function to first search the given value inside the array and get its corresponding key, and later remove the element using that key withunset()function.Please note that, if the value is found more than once, only the first matching key is returned.
Let's take a look at an example to understand how it actually works:
need an explanation for this answer? contact us directly to get an explanation for this answer