note 46762 deleted from function.array-search by crell

From: Date: Mon, 03 Jan 2022 14:50:06 +0000
Subject: note 46762 deleted from function.array-search by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217464@lists.php.net to get a copy of this message
Note Submitter: F?lix Cloutier <felixcca at yahoo dot ca> ---- There is no function to count the occurences of needle in haystack, so I made my own one... <?php function array_match($needle, $haystack) { if( !is_array($haystack) ) return false; $i = 0; while( (in_array( $needle, $haystack )) != FALSE ) { $i++; $haystack[array_search($needle, $haystack)] = md5($needle); reset($haystack); } return $i; } ?> I know it's a bit crappy, but don't ask me too much, I'm still only 13... ;)

« previous php.notes (#217464) next »