code_junkie

PHP Get URL Contents And Search For String

Nov 12th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. $url = 'http://my.url.com/';
  2. $data = file_get_contents( $url );
  3.  
  4. if ( strpos( 'maybe baby love you', $data ) === false )
  5. {
  6.  
  7. // do something
  8.  
  9. }
  10.  
  11. //The Answer No 3 Is good But a small Mistake in the function strpos() I have correction the code bellow.
  12.  
  13. $url = 'http://my.url.com/';
  14. $data = file_get_contents( $url );
  15.  
  16. if ( strpos($data,'maybe baby love you' ) === false )
  17. {
  18. // do something
  19. }
  20.  
  21. $string = file_get_contents('http://example.com/file.html');
  22. if(strpos ('maybe baby love you', $string) === false){
  23. //do X
  24. }
Add Comment
Please, Sign In to add comment