I have a function which will iterate over an array in PHP and all to search for a value.
function checkarrayvalues($term, $arr, $strict = false) {
foreach ($arr as $item) {
if (($strict ? $item === $term : $item == $term) || (is_array($item) && checkarrayvalues($term, $item, $strict))) {
return true;
}
}
So I've got it working for complete/exact matches. But I also need to test for partial matches, which is where I'm now lost. For instance, if someone searches for "Dall" and "Dallas" exists within the array, it needs to return a positive there as well.
What am I missing in how to do this?
Array looks like:
[Beau Rivage Resort & Casino] => Array
(
[name] => Beau Rivage Resort & Casino
[nid] => 100
[alias] => /BeauRivage
[guestrooms] => 1740
[meetingrooms] => 16
[largestmr] => 17000
[totalms] => 50000
[picture] => /2016-12/Beau-Rivage-Fallen-Oak-Golf-Course_0.jpg
[region] => SE
[segment] => GC
[city] => Biloxi
[state] => MS
[longstate] => mississippi
[address] => 875 Beach Boulevard
[zip] => 39530
[country] => United States of America
[distance] => 21.00
)
[Bellagio] => Array
(
[name] => Bellagio
[nid] => 103
[alias] => /Bellagio
[guestrooms] => 3933
[meetingrooms] => 50
[largestmr] => 45000
[totalms] => 200000
[picture] => /2016-12/Bellagio-exterior.jpg
[region] => SW
[segment] => BB
[city] => Las Vegas
[state] => NV
[longstate] => nevada
[address] => 3600 Las Vega Boulevard South
[zip] => 89109
[country] => United States of America
[distance] => 10.00
)