<?php
$vetor = [];
$tamanho = 0;

while (true) {
    $linha = trim(fgets(STDIN));
    if ($linha === "0") {
        break;
    }

    $comando = explode(" ", $linha);
    $op = $comando[0];

    if ($op == "1") {
        $x = $comando[1];
        $vetor[$tamanho] = $x;
        $tamanho++;
    }

    if ($op == "2") {
        if (isset($comando[1])) {
            $k = (int)$comando[1];
            $indice_real = $k - 1;

            if ($indice_real >= 0 && $indice_real < $tamanho) {
                for ($i = $indice_real; $i < $tamanho - 1; $i++) {
                    $vetor[$i] = $vetor[$i + 1];
                }
                unset($vetor[$tamanho - 1]);
                $tamanho--;
            }
        }
    }

    if ($op == "3") {
        for ($i = 0; $i < $tamanho; $i++) {
            echo $vetor[$i];
            if ($i < $tamanho - 1) {
                echo " ";
            }
        }
        echo "\n";
    }
}
?>

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: