Reputation: 1
I have an issue with readline() skipping some of the entries . It is done simple in the example below.
<?php
while(readline()!="stop")
{
echo "You have entered:". readline()."\n";
}
It gives me
1
2
You have entered:2
2
2
You have entered:2
3
3
You have entered:3
t
t
You have entered:t
5
You have entered:
5
5
You have entered:5
stop
Done.
The stop is read from the first time , the rest need to me entered twice. Any ideas? Thanks
Upvotes: 0
Views: 69
Reputation: 57121
In your echo, you are calling readline()
again, you need to store the first value and just output it in the echo...
while(($text = readline())!="stop")
{
echo "You have entered:". $text."\n";
}
Upvotes: 1