<?php
$vetor = [];
do {
$entrada = trim(fgets(STDIN));
if ($entrada === "0" || $entrada === "") {
break;
}
$comando = explode(" ", $entrada);
$tipoOp = $comando[0];
if ($tipoOp == 1) {
$vetor[] = $comando[1];
}
if ($tipoOp == 2) {
$k_usuario = (int)$comando[1];
$indice_real = $k_usuario - 1;
$n = count($vetor);
if ($indice_real >= 0 && $indice_real < $n) {
for ($i = $indice_real; $i < $n - 1; $i++) {
$vetor[$i] = $vetor[$i + 1];
}
unset($vetor[$n - 1]);
}
}
if ($tipoOp == 3) {
$primeiro = true;
foreach ($vetor as $x) {
if (!$primeiro) {
echo " ";
}
echo $x;
$primeiro = false;
}
}
} while ($entrada !== "0");
?>
To embed this project on your website, copy the following code and paste it into your website's HTML: