Ravuya's Articles!

Handy PHP snippets

Views: 7618

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!
Tips for Writing Portable Games, Bad Game Ideas #0, Pygame Introduction

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