文字列の切り出し
任意の文字列とその文字列の「何文字目」から「何文字」取得するかをプログラムする構文
hoge.php
<?php
$X = fgets(STDIN);
$Y = fgets(STDIN);
echo substr($X, 0, $Y) . "\n";
?>
substr関数
文字を切り出す関数
substr(任意の文字列、 X文字目から、 Y文字切り取る)
絶対値取得
abs関数
hoge.php
<?php
$num = fgets(STDIN);
echo abs($num), PHP_EOL;
標準入力
hoge.php
$input=explode(' ',trim(fgets(STDIN)));
echo $input[0];
echo $input[1];
echo $input[2]; .............
自動的に配列に入れてくれる
大文字から小文字に変換
strtoupper関数
[string] [to] [upper]ね、、読みづら、、、、
hoge.php
<?php
$str = trim(fgets(STDIN));
echo strtoupper($str) . "\n";
?>