note 45475 deleted from language.operators.arithmetic by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:58:17 +0000 |
| Subject: | note 45475 deleted from language.operators.arithmetic by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215402@lists.php.net to get a copy of this message | ||
Note Submitter: arjini at gmail dot com
----
When dealing purely with HTML, especially tables, or other things in "grids" the modulous
operator is really useful for splitting up the data with a seperator.
This snippet reads any gif files from the directory the script is in, prints them out and puts in a
break every 5th image.
<?php
$d = dir('./');
$i = 0;
while(false !== ($e = $d->read())){
if(strpos($e,'.gif')){
++$i;
echo '<img src="'.$e.'"/>'.chr(10);
if(!($i%5))
echo '<br/>';
}
}
?>
For tables just put </tr><tr> in place of the break.