[Solved] Get number from an url in PHP


With regexp:

$str="http:example.com/country/France/45";
preg_match('/http:example\.com\/country\/(?P<name>\w+)\/(?P<id>\d+)/', $str, $matches);
print_r($matches); // return array("name"=>"France", "id" => 45);

0

solved Get number from an url in PHP