Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 6th, 2012  |  syntax: None  |  size: 0.64 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. PHP- How do I search through an HTML document and extract certain strings in php?
  2. <?php
  3. $str = file_get_contents("comment.txt");
  4. preg_match_all ('/^(user/)/[A-Z0-9][A-Z0-9_-]+"$/i', $str, $preg);
  5. print_r ($preg);
  6. ?>
  7.        
  8. Array ( [0] => Array ( ) [1] => Array ( ) )
  9.        
  10. <html>
  11.   <body>
  12.     <a href="/user/boy30" />
  13.     <a href="/user/boy31" />
  14.     <a href="/user/boy32" />
  15.   </body>
  16. </html>
  17.        
  18. Array
  19. (
  20.     [0] => Array
  21.         (
  22.             [0] => "/user/boy30"
  23.             [1] => "/user/boy31"
  24.             [2] => "/user/boy32"
  25.         )
  26.  
  27.     [1] => Array
  28.         (
  29.             [0] => boy30
  30.             [1] => boy31
  31.             [2] => boy32
  32.         )
  33.  
  34. )