note 63942 deleted from function.strpbrk by bjori

From: Date: Tue, 04 Apr 2006 14:03:30 +0000
Subject: note 63942 deleted from function.strpbrk by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-107285@lists.php.net to get a copy of this message
Note Submitter: Alistair Reason: bad code ---- I was trying to use this function but my server does not support the latest PHP version so I bashed this togther. Seems to work well so far! Please feel free to comment or improve. function strpbrk($string, $search) { $lowest = -1; for ($i=0; $i<strlen($search) ; $i++) { $searchi = substr($search, $i, 1); $lowfind=strpos($string, $searchi); if ($lowfind>-1) { $lowest = min($lowest,$lowfind); if ($lowest==-1) $lowest = $lowfind; } } if ($lowest>-1) { return substr($string, $lowest); } else { return false; } }

« previous php.notes (#107285) next »