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