I am using the following code to pull some variables out of a string.
$query_string = ereg("p=(.*)&", "http://google.yahoo.com/bin/query?p=waxpack&hc=0&hs=0", $search_term);
echo "$search_term[1] <br>";
I am trying to pull the information between "p=" and the first "&", but I get a return of: waxpack&hc=0
Can anyone help me to get a return of just the word "waxpack"?
Thanks in advance.
Jared
Whatchew getting back?
How about:
$str = "http://google.yahoo.com/bin/query?p=waxpack&hc=0&hs=0"; $qry = ereg("p=([&]*)", $str, $st); echo $st[1];
???
adam
Thank You :-)
Got another question ... If I have a string of: ?p=%27waxpack&hc=0&hs=0
How do I search for the % sign, and delete that along with whatever 2 numbers are afer it, completely out?
Thanks in advance. :-)
$newstring = preg_replace("/%\d\d/","",$string);
will replace all the %\d\d in the string. if you want to confine it to the one just after the "=" do
$newstring = preg_replace("/=%\d\d/","=",$string);
-- rad