I've been wondering this myself. Unfortunately, I really don't think PHP has these special variables. I agree that it'd be nice. This could be a possible workaround. We'll name this function ppMatch:
Say you're doing a search for anything in between percentage signs: /%.*%/
PHP Code:
<?php
function ppMatch($matchString,$string,$pp) {
$splitTok = split($matchString, $string);
return $splitTok[$pp];
}
//example of usage
$searchString = "%.*%";
$string = "lalala %asdfasdf blah% asdfasdfasdf";
if (preg_match("/$searchString/", $string)) {
echo ppMatch($searchString,$string,0); //same as echo $`
echo ppMatch($searchString,$string,1); //same as echo $'
}
?>
Bookmarks