PHP loops
The top of the form of how to cycle, novice help ....
Share to: more
------Solution--------------------
$arr = Array (
' Images/small_case_1.jpg ',
' Images/small_case_2.jpg ',
' Images/small_case_3.jpg ',
' Images/small_case_4.jpg ',
' Images/small_case_5.jpg ',
' Images/small_case_6.jpg ',
' Images/small_case_7.jpg ',
' Images/small_case_8.jpg ',
' Images/small_case_9.jpg '
);
function Arr2li ($arr) {
$html = ";
if (Is_array ($arr) &&!empty ($arr)) {
$count = count ($arr);
for ($i =0; $i < $count; $i + +) {
$rem = $i% 3;
$html. = ($i!=0 && $rem ==0)? "\n\r\n\r ":" ";
$html. = ($rem ==0)? "
\n\r
\n\r ":" ";
$html. = sprintf ("
\n\r ", $arr [$i]);
$html. = ($i +1== $count)? "
\n\r" : "";
}
}
return $html;
}
/*
*/
echo Arr2li ($arr);
------Solution--------------------
while ($row =mysql_fetch_assoc ($result)) {
$ar []= $row;
}
foreach (Array_chunk ($ar, 3) as $v) {
echo "
\ n
";
foreach ($v as $VL) echo "
\ n ";
echo "
\ n\ n ";
}