Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Thiago Sabaia

Mostrar telefone diferente de acordo com estado da pessoa

Recommended Posts

Olá,

Estou desenvolvendo um site para um cliente, onde ele tem telefone em 7 estados no Brasil. Queria saber como faço para mostrar o telefone de acordo com o estado de onde o visitante se encontra.

 

por exemplo:

Eu sou do Rio, quando eu acessar o site quero que apareça o telefone (21) xxxx-xxxx

Quando alguém de SP acessar o site, aparecer o telefone (11) xxxx-xxxx

Compartilhar este post


Link para o post
Compartilhar em outros sites

Olá,

 

Aqui tem um artigo bem legal - http://trialforce.nostaljia.eng.br/?p=222

 

Exemplo:

<?php
$cidades = array(0 => 'Rio Claro',1 => 'Rio de Janeiro');
// $ip = '189.29.241.200'; // IP - Rio Claro
$ip = '187.67.119.247'; // IP - Rio de Janeiro
$geo =  unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip='.$ip));
var_dump($geo);
foreach($geo as $id => $cidade){
	if($cidade == $geo['geoplugin_city']){
		echo "A sua cidade é: " . $cidade;
	}
}
?>

Saída

array
  'geoplugin_request' => string '187.67.119.247' (length=14)
  'geoplugin_status' => int 200
  'geoplugin_credit' => string 'Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\'http://www.maxmind.com\'>http://www.maxmind.com</a>.' (length=145)
  'geoplugin_city' => string 'Rio De Janeiro' (length=14)
  'geoplugin_region' => string 'Rio de Janeiro' (length=14)
  'geoplugin_areaCode' => string '0' (length=1)
  'geoplugin_dmaCode' => string '0' (length=1)
  'geoplugin_countryCode' => string 'BR' (length=2)
  'geoplugin_countryName' => string 'Brazil' (length=6)
  'geoplugin_continentCode' => string 'SA' (length=2)
  'geoplugin_latitude' => string '-22.9' (length=5)
  'geoplugin_longitude' => string '-43.233299' (length=10)
  'geoplugin_regionCode' => string '21' (length=2)
  'geoplugin_regionName' => string 'Rio de Janeiro' (length=14)
  'geoplugin_currencyCode' => string 'BRL' (length=3)
  'geoplugin_currencySymbol' => string 'R$' (length=10)
  'geoplugin_currencySymbol_UTF8' => string 'R$' (length=2)
  'geoplugin_currencyConverter' => string '2.2457' (length=6)
A sua cidade é: Rio De Janeiro

Espero que ajude.

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.