Advertisement
scriptz-team

[PHP] SEARCH FOR TEXT iN ONE FiLE

May 20th, 2012
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2. header('Content-Type: text/plain');
  3. /* _____ _____ _ _____ _____ _____ _____ _____ _____
  4. ___| | __ |_| _ |_ _|___ ___|_ _| __| _ | |
  5. |_ -| --| -| | __| | | |- _|___| | | | __| | | | |
  6. |___|_____|__|__|_|__| |_| |___| |_| |_____|__|__|_|_|_|
  7. |s C R i P T z - T E A M . i N F O|████████████████████████████
  8.  
  9. $file -> in what file to search for $searchfor
  10. $searchfor -> what to search in $file
  11. */
  12. $file = "";
  13. $searchfor = "";
  14.  
  15. $contents = file_get_contents($file);
  16. $pattern = preg_quote($searchfor, '/');
  17. $pattern = "/^.*$pattern.*\$/m";
  18. if (preg_match_all($pattern, $contents, $matches)) {
  19. echo "Found matches:\n";
  20. echo implode("\n", $matches[0]);
  21. } else {
  22. echo "No matches found";
  23. }
  24. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement