I have SEF urls like /sitename/section/12-news-title and number 12 is id of the news. I need to get that number 12 in my php code, is there any out of the box method in PHP for this?
Depends how your URLs are being manipulated. It will be something like $_GET['id']
but it's hard to say without seeing how your URLs are being changed. Have a look in your .htaccess file and you should be able to work it out.
<?php
$_GET['id'] = "/sitename/section/12news-title"; // For example
if ( preg_match ( '/\d+/',$_GET['id'] ,$val ) )
{
print_r ( $val ) ; // Now $val will have the matched things.
}
else
{
print "Not matched
";
}
?>