Jump to content

preg_replace help


koolaidman52

Recommended Posts

I'm helping a freidn out with a website for our school basketball team and we recently ran into a problem. I rushed in thinking that with my superior knowledge of all things php I would be able to solve any complex error he may have, but I can't figure out the proper way to use preg_replace() in this situaition (or if I need to use it at all).

[code]
$blah = $_SERVER['REQUEST_URI'];
// $blah is /knights%20basketball/varsity/footer.php
$blah = str_replace("/footer.php", "", $blah);
// $blah is now /knights%20basketball/varsity
//the following line of code is the problem i can't figure out what to put as the first argument.
$blah = preg_replace('', '$1', $blah);
// the /knight%20basketball/ changes so I can't just have it search and remove that.
// $blah should now just be varsity
// but it isn't
echo $blah;
[/code]

please dont direct me to the php manual that didn't help
thanks for the help
Link to comment
https://forums.phpfreaks.com/topic/35278-preg_replace-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.