Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2. $input = $_POST['input'];
  3. $output = $_POST['output'];
  4. $replies = file('/this/is/where/my/file.is'); // I think I need to modify permissions on this file...
  5. $found = false;
  6. for ($i = 0; $i < count($replies); $i += 2) {
  7.     echo $replies[i];
  8.     echo '</br>';
  9.     echo $replies[i+1];
  10.     if (strcasecmp($input, $replies[i])) {
  11.         $replies[i+1] = $output;
  12.         $found = true;
  13.         break;
  14.     }
  15. }
  16.  
  17. if (!$found) {
  18.     array_push($replies, $input, $output);
  19. }
  20.  
  21. $file = fopen('/this/is/where/my/file.is');
  22. fwrite($file, join("\n",$lines));
  23. fclose($file);
  24.  
  25. echo $input;
  26. echo '</br>';
  27. echo $output;
  28. echo '</br>';
  29. echo "Saved!";
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement