note 76169 deleted from function.strpbrk by googleguy

From: Date: Sat, 15 Sep 2012 16:30:26 +0000
Subject: note 76169 deleted from function.strpbrk by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190792@lists.php.net to get a copy of this message
Note Submitter: user at example dot net ---- For PHP versions before 5: <?php function strpbrk( $haystack, $char_list ) { $strlen = strlen($char_list); $found = false; for( $i=0; $i<$strlen; $i++ ) { if( ($tmp = strpos($haystack, $char_list{$i})) !== false ) { if( !$found ) { $pos = $tmp; $found = true; continue; } $pos = min($pos, $tmp); } } if( !$found ) { return false; } return substr($haystack, $pos); } ?> Sadly this is about ten times slower than the native implementation.

« previous php.notes (#190792) next »