Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_GET['commands']) && isset($_GET['delimiter']))
- {
- $input = $_GET['commands'];
- $delimiter = $_GET['delimiter'];
- $arr = explode("\n", $input);
- $arr = array_map('trim', $arr);
- $arrResult = array();
- for($i = 0; $i < count($arr); $i++)
- {
- $line = explode($delimiter, $arr[$i]);
- $command = $line[0];
- $value = intval($line[1]);
- if($command == "add")
- $arrResult[] = $value;
- else
- array_splice($arrResult, $value, 1);
- }
- foreach($arrResult as $element)
- {
- echo $element. "<br>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment