fork(4) download
  1. <?php
  2.  
  3. function getLineNum0($haystack, $needle){
  4. $c = 1;
  5. $hsarr = explode("\n", $haystack);
  6. foreach($hsarr as $str){
  7. if(strstr($str, $needle)) return $c;
  8. $c++;
  9. }
  10. if($c >= count($hsarr)) return 'No hash found!';
  11. }
  12.  
  13. function getLineNum1($haystack, $needle){
  14. $hsarr = explode(PHP_EOL, $haystack);
  15. foreach($hsarr as $num => $str) if(strstr($str, $needle)) return $num + 1;
  16. return 'No hash found!';
  17. }
  18.  
  19. $your_file_contents = file_get_contents("php://stdin");
  20. $search_for_this_hash = "1e9eea56686511e9052e6578b56ae018";
  21.  
  22. $result = getLineNum1($your_file_contents, $search_for_this_hash);
  23. echo($result);
Success #stdin #stdout 0.03s 24404KB
stdin
APLF2J51 1a79a4d60de6718e8e5b326e338ae533
EEQJE2YX 66b375b08fc869632935c9e6a9c7f8da O87IGF8R
c458fb5edb84c54f4dc42804622aa0c5 APLF2J51
B7TSW1ZE 1e9eea56686511e9052e6578b56ae018
EEQJE2YX affb23b07576b88d1e9fea50719fb3b7
stdout
4