note 67808 added to function.strpos

From: Date: Wed, 05 Jul 2006 18:56:52 +0000
Subject: note 67808 added to function.strpos
Groups: php.notes 
Request: Send a blank email to php-notes+get-114387@lists.php.net to get a copy of this message
If you're wanting a simple "strpos" using a pattern and don't need the complexity of multi_strpos below, this function (for PHP 4.3.0+) returns the regex position. function preg_pos($sPattern, $sSubject, &$FoundString, $iOffset = 0) { $FoundString = NULL; if (preg_match($sPattern, $sSubject, $aMatches, PREG_OFFSET_CAPTURE, $iOffset) > 0) { $FoundString = $aMatches[0][0]; return $aMatches[0][1]; } else { return FALSE; } } It also returns the actual string found using the pattern, via $FoundString. ---- Server IP: 216.194.113.175 Probable Submitter: 66.217.117.38 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.strpos.php Edit -- http://master.php.net/note/edit/67808 Del: integrated -- http://master.php.net/note/delete/67808/integrated Del: useless -- http://master.php.net/note/delete/67808/useless Del: bad code -- http://master.php.net/note/delete/67808/bad+code Del: spam -- http://master.php.net/note/delete/67808/spam Del: non-english -- http://master.php.net/note/delete/67808/non-english Del: in docs -- http://master.php.net/note/delete/67808/in+docs Del: other reasons-- http://master.php.net/note/delete/67808 Reject -- http://master.php.net/note/reject/67808 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114387) next »