note 96614 added to function.substr
| From: | EnricoGiancipoli/fr4nk | Date: | Mon, 08 Mar 2010 14:01:42 +0000 |
| Subject: | note 96614 added to function.substr | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166777@lists.php.net to get a copy of this message | ||
<?php
//How to get a subtring between a starting string and an ending string
$s = "ireallylove2000onion2001chips"; //original sting
$string_a = '2000'; //starting string
$string_b = '2001'; //ending string
$x = strpos($s, "$string_a");
$x = $x + strlen($string_a);
$y = strpos($s, "$string_b");
$y = strlen($s) - $y;
$z = substr($s, $x, -$y); //returns the substring beetween 2000 and 2001
echo "$z"; //prints onion
?>
----
Server IP: 69.147.83.197
Probable Submitter: 151.15.163.113
----
Manual Page -- http://www.php.net/manual/en/function.substr.php
Edit -- https://master.php.net/note/edit/96614
Del: integrated -- https://master.php.net/note/delete/96614/integrated
Del: useless -- https://master.php.net/note/delete/96614/useless
Del: bad code -- https://master.php.net/note/delete/96614/bad+code
Del: spam -- https://master.php.net/note/delete/96614/spam
Del: non-english -- https://master.php.net/note/delete/96614/non-english
Del: in docs -- https://master.php.net/note/delete/96614/in+docs
Del: other reasons-- https://master.php.net/note/delete/96614
Reject -- https://master.php.net/note/reject/96614
Search -- https://master.php.net/manage/user-notes.php