note 41208 modified in function.strpos by aidan

From: Date: Thu, 10 Jun 2004 06:56:45 +0000
Subject: note 41208 modified in function.strpos by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70810@lists.php.net to get a copy of this message
You can use this function to find ANY occurence of a string in an array - no matter if it is just part of one of the array elements. it returns the key of the first found occurence or false <?php function search_array($needle,$haystacks) { $found=false; foreach ($haystacks as $key => $haystack) { if (!(strpos($haystack,$needle)===false)) { $found=$key; break; } } return ($found); } ?> --was-- You can use this function to find ANY occurence of a string in an array - no matter if it is just part of one of the array elements. it returns the key of the first found occurence or false function search_array($needle,$haystacks) { $found=false; foreach ($haystacks as $key => $haystack) { if (!(strpos($haystack,$needle)===false)) { $found=$key; break; } } return ($found); } http://www.php.net/manual/en/function.strpos.php

« previous php.notes (#70810) next »