Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading data from a text file 1

Status
Not open for further replies.

overflo

Technical User
Feb 10, 2003
70
AU
I'm trying to make sense of this code.
It's a simple script to display data from a text file
<?php
if (file_exists($filename)){

$data = file($filename);
$lineno=0;
foreach ($data as $line) {
$lineno +=1;
echo nl2br($line);
if (($lineno % 2) == 0) {
echo '<hr width="50%" align="left"/> <br />';
}
}
}
?>

Can anyone tell me what the % sign in ($lineno % 2) means?

Thanks in advance
 
overflo,

You can actually do this as well (line numbers included in the foreach):

Code:
$data = file($filename);
foreach ($data as $lineno => $line) {
// your code here ...
}

Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top