EDIT: Apparently the original post was edited, changing the question. The answer relating to the new question is on the next page.
However, this applies well (and fills in some details missing in the next post) if you want to find "blez" AND "blez", or two of the same markers, not different markers.
Several methods...
1.
PHP Code:
list($extra,$YOURVAR,$extra2) = explode('blez',$string,3);
$YOURVAR now holds that value.
2.
PHP Code:
$YOURVAR = substr($string,strpos($string,'blez')+strlen('blez'),(strpos($string,'blez',strpos($string,'blez')+strlen($marker))-(strpos($string,'blez')+strlen('blez'))));
Again, $YOURVAR now holds the value.
I think the substr method would theoretically best less server load or some such, but, hey, I think explode is a little bit friendlier 
More info:
1.
list() acts like an array, but with specific variables. You could just use $myvar = explode(...) instead, and $myvar[1] (since arrays start at zero, 1 is the second value) would be what you want.
explode() splits a string into chunks (in an array) at a marker. The third parameter is limiting the number of outputs to three, so the next blez, if it were to occur would not split again, causing confusion.
2. substr(STRING, INT START, INT LENGTH) (aka sub-string)
So... you set which string to use, what point to start and how long it should be. This can all be determined using strpos() (aka string-position, within a string):
strpos(STRING, INT START, INT OFFSET)
So... which string, where to start, then, if added, how far into the string to start looking. We use this here because you need two instances of the same string, so you need to be sure not to just find the first occurance twice.
Note: strlen($var) just returns to length of $var, helping with the offset and such.
For a better understanding of method two, here are two ways to look at it:
First, make it generic. Let's use a variable instead of your randomly chosen marker:
$marker = 'blez';
substr($string,strpos($string,$marker)+strlen($marker),(strpos($string,$marker,strpos($string,$marker)+strlen($marker))-(strpos($string,$marker)+strlen($marker))));
Now, to further explain, we can seperate that into lots of parts:
PHP Code:
$marker = 'blez';
//Here's what we're starting with--
substr($string,strpos($string,$marker)+strlen($marker),(strpos($string,$marker,strpos($string,$marker)+1)-(strpos($string,$marker)+strlen($marker))));
//To begin...
$len = strlen($marker); //$len is now length of marker
$pos1 = strpos($string,$marker); // find pos1 (first position) of marker in string
//already, it looks a lot simpler:
substr($string,$pos1+$len,(strpos($string,$marker,$pos1+$len)-($pos1+$len)));
//Now, to continue:
substr($string,$pos1+$len,(strpos($string,$marker,$pos1+$len)-($pos1+$len)));
//We don't want to include the marker, so let's add it's length to the starting point--
$start = $len + $pos1;
//Now, even more simple:
substr($string,$start,(strpos($string,$marker,$start)-$start));
//Let's find the second occurance of $marker:
$pos2 = strpos($string,$marker,$start);
//find position of $m in $s AFTER starting point, $start
//So...
substr($string,$start,($pos2-$start));
//Let's simplify the end...
//Since we want what is BETWEEN $start and $pos2, let's just subtract:
$length = ($pos2-$start);
//Now, looks a lot nicer:
substr($string,$start,$length);
//So, here's all of that without the 'work':
$len = strlen($marker);
$pos1 = strpos($string,$marker);
$start = $len + $pos1;
$pos2 = strpos($string,$marker,$start);
$length = ($pos2-$start);
$MYVAR = substr($string,$start,$length);
EDIT: Note that in the time it took me to write all of the comments and such, I now find 5 posts have been added... I *was* going to be the first reply
Bookmarks