I have a lot URLs in my site that look like: http://localhost/DIRECTORY/FINAL/ref.php?id=category

Now, I need a PHP function to search for = Sign and return all the text after that i.e. 'category'

Is this possible, if so can anyone help

$id = $_GET['id'];


No with out that one! Because, I have Id,Ref,Profile,Article,Event ... I can not make the get function for all. I was thinking, something handy with the regex function

Thank you for trying to help me guys, but I have this problem wich wasted four hours of my time now, and I can't get it fixed.

    function seo($seo_type){
    if(isset($_GET['a_id']) && !empty($_GET['a_id'])) {

    $number = $_GET['a_id'];
    $query = "SELECT $seo_type FROM d_articles WHERE a_id = '$number'";
    $result = mysql_query($query);

    { echo "$row[$seo_type] - ";    }


What the above function does is, get id of url ex. site.com/article.php?a_id=77
Now, the function calling is like this, <?php echo seo('page_title'); ?>

Now, when you call the function, it searches page_title FROM d_articles wheere
a_id = 77

Now, it does query and gets results from sql and echos it. Which is good.
But, what if the url does not end with articles.php?a_id=77
What if I have another url that is referece.php?id=22 or user.php?id=44

So, the question boils down to

how can you check what kind of id exists and perform seperte functions as per the function that exits


So you are trying to get either a_id or id from the URL, depending on which one exists?

if(isset($_GET['a_id']) && !empty($_GET['a_id'])){
    $number = $_GET['a_id'];
} elseif (isset($_GET['id']) && !empty($_GET['id'])){
    $number = $_GET['id'];

You can add as many variations as you need.

If you really want to get the whole string after the ? you can use something like:

$id = strstr($_SERVER['PATH_INFO'], '?');
$id = str_replace('?','',$id);