Advertisement
garfield

[PHP]: Detectar/Contar Quebras de linha em string.

Nov 5th, 2011
675
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. /*================================================================
  3.          _ ____ _____ __ __
  4.         (_) _ \ ___ | _ _ | _ __ __ | \ / |
  5.         | | | _) / __ | | | / _ \ / _ `| | \ / | |
  6.         | | __ / \ __ \ | | __ / (_ | | | | |
  7.         |_|_| |___/ | _ | \ ___ | \ __,_|_| | _ |
  8.  
  9.             Criado por SuYaNw Dácio
  10.             www.ips-team.blogspot.com
  11.              Contar Quantas quebras de linha Contem na frase.
  12.  
  13. ===============================================================*/
  14.  
  15. function sQuebrasDeLinhas($Str) // By: [iPs]SuYaNw
  16. {
  17.     /*
  18.         Esta função verifica e conta quantas quebras de linha há em uma string.
  19.         e returna á quantidade de quebras de linhas.
  20.     */
  21.    
  22.     $Out = explode("\n", $Str);
  23.     return Count($Out) -1;
  24. }
  25.  
  26.  
  27. // Modo de uso(opcional):
  28. for($i =0; $i != sQuebrasDeLinhas($String); ++$i)
  29. {
  30.         echo $i;
  31. }
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement