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?
+1
A:
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.
Ben Shelock
2010-03-19 12:12:29
Ok that worked, I'm using Joomla!
newbie
2010-03-19 12:28:35
+3
A:
<?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 \n";
}
?>
pavun_cool
2010-03-19 12:20:23