$input1 = trim(fgets(STDIN)); for ($i = 1; $input1 >= $i; $i++) { $input2[] = trim(fgets(STDIN)); } var_dump($input2);