current code
eregi("(.*)/index.php$", $scriptName, $regs)
thinking along lines of
preg_match("(.*)/index.php$", $scriptName, $regs)
but not sure what the $regs bit is and also what I need to change in the brackets to make it work?
current code
eregi("(.*)/index.php$", $scriptName, $regs)
thinking along lines of
preg_match("(.*)/index.php$", $scriptName, $regs)
but not sure what the $regs bit is and also what I need to change in the brackets to make it work?
preg_match_all("/(.*)\/index.php$/", $scriptName, $regs)
Note you can use most characters as regex delimiters in PHP, e.g. ~
.
but not sure what the $regs bit is and also what i need to change in the brackets to make it work?
$regs
will be the matches. preg_match_all()
has this behaviour, with the third argument. It is passed by reference, so you can simply start subscripting $regs
if there were successful matches. [0]
will have the entire match, and [1]
will have the portion proceeding /index.php
at the end of the string.
As for changes in brackets, I've always called those parenthesis so I will assume that is what you meant (sorry for nitpicking). Are you referring to the arguments inside the function's parenthesis, or the matching group in the regex itself? Either way, just use the code above :)