Help us understand the problem. What is going on with this article?

PHPの標準入力について

// 標準入力からの入力値を変数に代入します
$single_line_input = fgets(STDIN);

// 取得した入力値を半角スペースで分解します
$array = explode(" ", $input_line);
ex)入力12 13 14 15
  →[12,13,14,15]

// 単一行の入力の場合はこれだけで各入力値が配列の要素として使えます

・標準入力が複数行の場合

// 標準入力を一行ずつ配列に代入します
//trimは入力された文字列の前後の空白をなくす
while ($line = fgets(STDIN)) {
$tmp[] = trim($line);
}

// 配列の各要素をさらに分解します
foreach ($tmp as $key => $value) {
$array[] = explode(" ", $value);}

run_way
現在28歳で小売業をしております。 今年、エンジニアに転職するべく行動します。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした