Advertisement
yacked2

[php] dvovrst:Crypt

Mar 24th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.72 KB | None | 0 0
  1. <?php
  2.  
  3. $vhod = "delfin";
  4. echo Kodiraj($vhod);
  5.  
  6. function Kodiraj($niz)
  7. {
  8.     $value = strlen($niz);
  9.     $value = $value.'.0';
  10.     $polovica = $value / 2;
  11.     $ena = round($polovica);
  12.     $dve = $value - $ena;
  13.     $ena--;
  14.     $array = str_split($niz);
  15.  
  16.     foreach($array as $index => $element)
  17.     {
  18.         if($index <= $ena)
  19.         {
  20.             $prva[] = $element;
  21.         }
  22.         else
  23.         {
  24.             $druga[] = $element;
  25.         }
  26.  
  27.     }
  28.  
  29.     $output="";
  30.  
  31.     if(count($prva)==count($druga))
  32.     {
  33.         foreach($prva as $index => $element)
  34.         {
  35.             $output.=$element;
  36.             $output.=$druga[$index];
  37.         }
  38.     }
  39.     else
  40.     {
  41.         foreach($druga as $index => $element)
  42.         {
  43.             $output.=$prva[$index];
  44.             $output.=$element;
  45.    
  46.         }
  47.    
  48.         $output.= $prva[count($prva)-1];
  49.     }
  50.  
  51.     return $output;
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement