Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_GET['commands'])&&isset($_GET['delimiter'])){
- $command= $_GET['commands'];
- $delimiter = $_GET['delimiter'];
- $command = explode("\n", $command);
- $command = array_map('trim', $command);
- $result=[];
- for($i=0; $i<count($command); $i++){ // sizeof-count
- $parts = explode($delimiter, $command[$i]);
- $key = $parts[0];
- $value = $parts[1];
- if($key == "add"){
- // $result[$i] = $parts[1];
- array_push($result,$value);
- }
- else{
- array_splice($result,$value,1);
- }
- // if($parts[0] == "add"){
- // $result[$i] = $parts[1];
- // }
- // else if($parts[0]== "remove"){
- // array_splice($result,$parts[1],1);
- // }
- }
- for($i=0; $i<count($result); $i++){
- echo $result[$i]."<br>";
- }
- // for($i=0; $i<sizeof($result); $i++){
- // echo $result[$i]."<br>";
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement