html - PHP selecting images with specific width and building a grid -
i'm having trouble building dynamic grid php this:
i have array containing images in various sizes, either 900 or 1800 in width.
looks this:
$images = array('img_1_900.jpg', 'img_2_900.jpg', 'img_3_1800.jpg', 'and on');
is there smart way this? i'm kind of new php-thing, hints nice. here's got far:
$img_count = count($images); $i = 1; while($i <= $img_count){ list($width) = getimagesize($images[$i]); if($width = 1800){ } $i++; }
i know nothing, don't know go here. hope kind soul me little along. can't float them, because need stay on line after resize, kind of table/table-div has it. guess.
thanks in advance!
if image array allway build in same way... , not getting sorted...
$i = 0; $html = "<table cellpadding='0' cellspacing='10' border=1>" foreach($image $img){ if($i == 0) $html .= "<tr>"; if($i < 2){ $html .= "<td><img src='{$img}' /></td>"; $i++; } if($i == 2){ $html .= "</tr><tr>"; $html .= "<td colspan=2><img src='{$img}' /></td>"; $i = 0; } } echo $html;
Comments
Post a Comment