Is is possible to use wildcards with array_search? I want to search for part of a string and then
something like(with an asterisk)
print $pos = array_search('abitofastring%', $vars['myarray']);
unset($vars['myarray'][$pos]);
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, but you can use regular expressions (which supports wildcards) and the
preg_grepfunction.Example:
The array then is:
As it can be complicated to write regular expression patterns, it might be handy to have a helper function that converts your SQL LIKE pattern into a regular expression so this can be more easily used: