Advertisement
jeffersonjulio

Invertendo String e retornando a Segunda Maiuscúla

Feb 4th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1.    function inverte_caracteree_muda_segunda_maiuscula($str){
  2.         $ct_str     = strlen($str);
  3.         $n_str      = null;
  4.         $n_str_r    = null;
  5.         for($i = $ct_str; $i >= 0; $i--){
  6.             $n_str .= $str[$i];
  7.         }
  8.         for($i = 0; $i <= $ct_str; $i++){
  9.             $quebra_indice = $i + 1;
  10.             $n_str_r .= ($quebra_indice % 2 == 0) ? strtoupper($n_str[$i]) : strtolower($n_str[$i]);
  11.         }
  12.         return $n_str_r;
  13.     }
  14.     echo inverte_caracteree_muda_segunda_maiuscula("Jefferson Julio :D");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement