Bandit Design » Our Design Our Portfolio Contact Us
Tutorials TumbleLog Our Thoughts
Quite often at Bandit Design while we're working on your project, we'll stumble upon interesting or humourous things -- so we thought why not share them with the world!
RSS iPhone Random Archive « Home

Bandit Design

This is a TumbleLog authored at the desks of Bandit Design. We're a small web and graphic design studio based in Wellington, New Zealand.

Visit Bandit Design ยป

2 years ago

PHP: array_search with Partial Matching

Ever wanted to check for a value in an array with a partial match? Same.

// array_search with partial matches
function array_find($needle, $haystack) {
	if(!is_array($haystack)) return false;
	foreach ($haystack as $key=>$item) {
		if (strpos($item, $needle) !== false) return $key;
	}
	return false;
}

Enjoy.

1 note

Loading...