fork(1) download
  1. <?php
  2.  
  3. $log = <<<FIM
  4. ##################################################
  5. ----------------------------------------
  6. Nome: nome_user,
  7. Email: email@user.com,
  8. -------------------------------
  9. ,
  10. ----------------------------------------
  11. ##################################################
  12. FIM;
  13.  
  14. echo my_extract( $log, 'Email:', ',' ) . PHP_EOL;
  15. echo my_extract( $log, 'Nome:', ',' ) . PHP_EOL;
  16. echo my_extract( $log, 'Batata:', ',' ) . PHP_EOL;
  17.  
  18.  
  19. function my_extract( $text, $start, $end ) {
  20. $pos1 = strpos( $text, $start );
  21. if( false === $pos1 ) return 'Não encontrado';
  22. $pos1 += strlen( $start );
  23. $pos2 = strpos( $text, $end, $pos1 );
  24. return trim( substr( $text, $pos1, $pos2 - $pos1 ) );
  25. }
  26.  
  27.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
email@user.com
nome_user
Não encontrado