How can i extract the portion of a string giving the beginning and the end position?
I know there is a method called substr() but is not what im looking for (the third parameter is lenght of the portion..)
How can i extract the portion of a string giving the beginning and the end position?
I know there is a method called substr() but is not what im looking for (the third parameter is lenght of the portion..)
If you have the start and end positions, the length is just end - start:
$string = "The quick brown fox jumped over the lazy dog";
$start = 4;
$end = 15;
substr($string, $start, $end - $start); //=> "quick brown"
See this in action at http://www.ideone.com/LRfYT.