Posted By

guiiipontes on 11/23/10


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

AllKnightAccess
luman
tyfi84


get location with php


 / Published in: PHP
 

  1. <?php
  2.  
  3. ( ( (float)phpversion() < 5.3 ) ) ? die ( 'fail amigo.' ) : '';
  4.  
  5. $site = file_get_contents( "http://www.google.com.br/search?hl=pt-BR&q=VBXMCBVFKJSHDKHDKF" );
  6.  
  7. $getLocationViaGoogle = function ( $html ){
  8. $regex = "#<\w+\s\w+=\"tbos\">([^<]{3,})<\/\w+>#i";
  9. preg_match_all( $regex, $html, $matches );
  10. return $matches[1][0];
  11. };
  12.  
  13. print $getLocationViaGoogle( $site );
  14.  
  15. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: dnthomps on November 24, 2010

I receive "Parse error: syntax error, unexpected T_FUNCTION in /home/user/mysite.com/test.php on line 7."

Any ideas?

Posted By: dnthomps on November 24, 2010

It was the PHP version. Switched over to 5.3 and it worked. Took of the .br in the domain and it now gives me a location of West Orange, NJ. I assume this is the server's location than?

You need to login to post a comment.