Any questions involving matching text strings to patterns - the pattern is called a "regular expression."
Moderator: General Moderators
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Sat Jan 21, 2006 11:18 pm
I've got a class that i've created that basically allows me to create a url or use the current one and add or take out variables.
EX: sub("var1")
Code: Select all
http://www.site.com/index.php?var1=hello&var2=world => http://www.site.com/index.php?var2=world
The idea that i am having is that there should be a better way to do so than i am using. is there a way to find the variable in a string and replace it with nothing? the way i'm doing it is just to search either ?var1= or &var1= and finding the next & or end of string and replacing that portion with ''. Is there a preg_replace way of doing this?
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat Jan 21, 2006 11:21 pm
Check out $_SERVER['argv']
This will give you an array of arguments.
Code: Select all
echo '<HR><PRE>'; print_r($_SERVER); echo '</PRE>';
Zoram
Forum Contributor
Posts: 166 Joined: Sun Aug 18, 2002 3:28 pm
Location: Utah
Contact:
Post
by Zoram » Sat Jan 21, 2006 11:25 pm
You may have just destroyed an hour of programming with that statement... thanks
hawleyjr
BeerMod
Posts: 2170 Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA
Post
by hawleyjr » Sat Jan 21, 2006 11:27 pm