Guest User

Untitled

a guest
Jun 8th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | None | 0 0
  1. <?php
  2. $inputFile = fopen("ksiazka1.txt", "r") or die("Nie mozna otworzyc pliku");
  3.  
  4. $arr = array();
  5.  
  6. while(!feof($inputFile))
  7. {
  8.     $character = ord(fgetc($inputFile));
  9.     #Sprawdzenie czy znak znajduje sie w przedziale a-z, A-Z
  10.     if($character >= 65 and $character < 90 or $character >= 97 and $character < 122)
  11.     {
  12.         array_push($arr, $character + 1);
  13.     }
  14.     #Jezeli znak to z lub Z - zamiana na a, A
  15.     else if($character == 90 or $character == 122)
  16.     {
  17.         array_push($arr, $character - 25);
  18.     }
  19.     #Pozostawienie znaku bez zmian
  20.     else
  21.     {
  22.         array_push($arr, $character);
  23.     }
  24. }
  25. fclose($inputFile);
  26.  
  27.  
  28. $output = "";
  29. foreach($arr as $val)
  30. {
  31.     $output .= chr($val);
  32. }
  33.  
  34. $outputFile = fopen("ksiazka2.txt", "w");
  35. fwrite($outputFile, $output);
  36. fclose($outputFile);
  37.  
  38. echo "Sukces";
  39.  
  40.  
  41. ?>
Add Comment
Please, Sign In to add comment