Ravuya's Articles!

Handy PHP snippets

Views: 12108

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!
Bad Pen & Paper Games, Handy PHP snippets, Bad Game Ideas #0

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