fork download
  1. <?php
  2.  
  3. echo 'https://w...content-available-to-author-only...p.net/manual/pt_BR/function.substr.php';
  4. echo PHP_EOL;
  5. $protocolo = 'Protocolo: ';
  6. $exemplo = '48498454648';
  7. $texto = '
  8. fjsafjklasjçlk jfdjklsaj fklsadf
  9.  
  10. fkasjdçjsklaf fdf safsfda Protocolo: 48498454648xxxxx fkj lasjfçklasjf sfladkjsda
  11. klasjdfçklsaj fçkljafklsjalk
  12.  
  13. fsadjçfklsajlfjsaffsdal
  14. fçlasd fjklasfjdkljfsda
  15. ';
  16.  
  17. $busca_pro = strripos($texto, $protocolo);
  18. $posicaoIni = ($busca_pro + strlen($protocolo));
  19. $tamanhoProtocolo = strlen($exemplo);
  20.  
  21. echo substr($texto, $posicaoIni, $tamanhoProtocolo);
  22. echo PHP_EOL;
  23. echo '..................................';
  24. echo PHP_EOL;
  25. echo 'https://w...content-available-to-author-only...p.net/manual/pt_BR/function.preg-match.php';
  26. echo PHP_EOL;
  27. $match = [];
  28. preg_match('/Protocolo:\s*(\d+)/', $texto, $match);
  29. print_r($match);
Success #stdin #stdout 0.03s 26380KB
stdin
Standard input is empty
stdout
https://w...content-available-to-author-only...p.net/manual/pt_BR/function.substr.php
48498454648
..................................
https://w...content-available-to-author-only...p.net/manual/pt_BR/function.preg-match.php
Array
(
    [0] => Protocolo: 48498454648
    [1] => 48498454648
)