Advertisement
Guest User

Untitled

a guest
Jul 4th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2. if (isset($_GET['commands'])&&isset($_GET['delimiter'])){
  3.  
  4. $command= $_GET['commands'];
  5. $delimiter = $_GET['delimiter'];
  6. $command = explode("\n", $command);
  7. $command = array_map('trim', $command);
  8.  
  9. $result=[];
  10.  
  11. for($i=0; $i<sizeof($command); $i++){
  12.  
  13. $parts = explode($delimiter, $command[$i]);
  14.  
  15. if($parts[0] == "add"){
  16. $result[$i] = $parts[1];
  17. }
  18. else if($parts[0]== "remove"){
  19. array_splice($result,$parts[1],1);
  20. }
  21.  
  22. }
  23.  
  24. for($i=0; $i<sizeof($result); $i++){
  25. echo $result[$i]."<br>";
  26. }
  27.  
  28. }
  29.  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement