Ravuya's Articles!

Handy PHP snippets

Views: 11911

Here's a handy snippet you can use to read out search terms from a google referer URL in PHP:
        function parse_google_url($url) {

$i = strpos($url, "q=");
$sub_url = substr($url, $i + 2);
$last_pos = strpos($sub_url, "&");
$sub_url = substr($sub_url, 0, $last_pos);
$decoded = urldecode($sub_url);

return $decoded;
}

I hope you find a use; if so please give me credit or drop a line and let me know.


See other articles!
Handy PHP snippets, Tips for Writing Portable Games, Bad Game Ideas III

back
Copyright 2003-2021 ravuya. Front page web design originally by Josh Powell.