I am new to php $tmp = www.domain.com/hhhhh.html?cat5 now I just want the string cut by '?', so it would look www.domain.com/hhhhh.html Waiting for answer, thanks
If it is for that specific string, do: $tmp = str_replace('?cat5','',$tmp); PHP: If you do not know what is after the ?, use preg_replace: $tmp = preg_replace('/\?(.*)/','',$tmp); PHP:
I'd go with this if you just want to strip the URL variables. No need to use regex is there's.... no need
$string = explode("?", $tmp); echo $string[0]; or $string=substr($tmp,strpos($tmp,"?")+1); echo $string;