note 74286 added to function.strpos
| From: | gal_chen123 at hotmail dot co dot il | Date: | Tue, 03 Apr 2007 16:57:59 +0000 |
| Subject: | note 74286 added to function.strpos | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-125056@lists.php.net to get a copy of this message | ||
this function returns the text between 2 strings:
function get_between ($text, $s1, $s2) {
$mid_url = "";
$pos_s = strpos($text,$s1);
$pos_e = strpos($text,$s2);
for ( $i=$pos_s+strlen($s1) ; ( ( $i < ($pos_e)) && $i < strlen($text) ) ; $i++ ) {
$mid_url .= $text[$i];
}
return $mid_url;
}
if $s1 or $s2 are not found, $mid_url will be empty
to add an offset, simply compare $pos_s to the offset, and only let it continue if the offset is
smaller then $pos_s.
----
Server IP: 212.199.163.191
Probable Submitter: 87.68.148.198
----
Manual Page -- http://www.php.net/manual/en/function.strpos.php
Edit -- https://master.php.net/note/edit/74286
Del: integrated -- https://master.php.net/note/delete/74286/integrated
Del: useless -- https://master.php.net/note/delete/74286/useless
Del: bad code -- https://master.php.net/note/delete/74286/bad+code
Del: spam -- https://master.php.net/note/delete/74286/spam
Del: non-english -- https://master.php.net/note/delete/74286/non-english
Del: in docs -- https://master.php.net/note/delete/74286/in+docs
Del: other reasons-- https://master.php.net/note/delete/74286
Reject -- https://master.php.net/note/reject/74286
Search -- https://master.php.net/manage/user-notes.php