python
for i in range(10):
print(i+1)
PHPは仕方ないけど行数多くなってしまうな
<?php
for ($i=1; $i<=10; $i++){
print($i . "\n");
}
?>
じゃ次
python
for i in range(int(input())):
print(i+1)
PHPだと、pythonのように直接入れ込む、ということはできないようです。
つまり下の$i<=$N
の部分を$i<=fgets(STDIN)
のようにはできないようです。
何故か調べてますがなかなかそれらしきものは見つからず。
仕方ないのでこのままにします。汗
<?php
$N = trim(fgets(STDIN));
for ($i=1; $i<=$N; $i++){
print($i . "\n");
}
?>
じゃ次
python
for i in list(map(int,input().split())):
print(i)
PHP
思った通り、直接やる方法はここでもあまりうまくいかないですね
<?php
$A = explode(" ",fgets(STDIN));
foreach ($A as $i){
print($i . "\n");
};
?>
じゃ次
python
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
print(A[i])
PHP
<?php
$N = trim(fgets(STDIN));
$A = explode(" ",fgets(STDIN));
for ($i=0; $i<=$N; $i++){
print($A[$i]."\n");
}
?>