ok I’m using geoio.com to find out a users location, I get back a load of info based on this bit of code
<?php $_SESSION['geo'] = file_get_contents("http://api.geoio.com/q.php?key=********=geoip&d=comma&q=" . getenv('REMOTE_ADDR') . ""); ?>
The above set’s the session variable to
Chesterfield,Derbyshire,United Kingdom,Greenfrog Computing Ltd Managed Broadband Adsl Ass,53.2500,-1.4167,GB)
So all I want to do, is if that session variable contains United States , is redirect users to a different URL called /us/
How do I ‘find’ the United States bit and act on it.
Any help greatly appreciated ! (note I edited out the API key)
Cheers
Rich 🙂
Use strpos() which returns
falseif the string was not found, or the index if it was.