I am trying to GET the int from the following string
member.php?3-bradthor
I have tried using the following code
$query = parse_url($str, PHP_URL_QUERY);
$intval = preg_replace("/[^0-9]/","",' $query');
However I don't think this is a fool proof solution? what Imporovements could I make to this code/what code should I use to get the integer from the above string. Thanks for the help :)
Check this,
$str = 'member.php?3-bradthor';
$query = parse_url($str, PHP_URL_QUERY);
$intval = preg_replace("/[^0-9]/","",$query);// remove single quotes.
echo $intval;
Working demo
Because of how integers are parsed in PHP you can simple use
$query = parse_url('member.php?3-bradthor', PHP_URL_QUERY);
$intval = intval($query);
if will work only when number in the begining of string.
Less dirty solution is to use for example mod_rewrite.