I'm looking for an alternative function that works the same as in_array but which could also check if the search term only contains a part of the given element instead of the whole element:
Currently working with the following script:
$attributes = array('dogs', 'cats', 'fish');
if (in_array($attributes, array('dog','cats','fishess'), true )) {
* does something for cats, but not for dogs and fish
because the function only checks if the given term is identical to the word in the array instead of only a part of the word *
}
How would I build my up function so that it passes words which only contain parts of word in the array aswell?
Preferred example would look something like this:
$words = array('fish', 'sharks');
if (*word or sentence part is* in_array($words, array('fishing', 'sharkskin')){
return 'your result matched 2 elements in the array $words
}