Is “fscanf(STDIN,’%d’,$v);” the shortest way to read line in php?
For this specific case (reading first integer from input line), I use:
$v=fgets(STDIN)+0;
2 Likes
You can use fgetcsv
. It is worth it in case when you have more than 4 value on a line you can use:
$a=fgetcsv(STDIN,0,' ');