Why don't you just put a line break after each 4th element?
function PrintFolio($aaPh) //aaPh =associative array place holder
{
//loop through the array
for($row = 0; $row < Count($aaPh); $row++) //looping through the rows
{
if (!$row || !($row%4)) {
if ($row) echo '</div>'; // close previously opened divs
echo '<div class="row flush">'; //open div
}
/* show your picture code here */
}//end loop
echo '</div>';
}//end function
Here is an update after your comments. Because you do not need values of your associative array, only keys, the code can be changed as follows:
function PrintFolio($aaPh) //aaPh =associative array place holder
{
//loop through the array
$row=0;
foreach(array_keys($aaPh) as $img) //looping through array keys only
{
if (!$row || !($row%4)) {
if ($row) echo '</div>'; // close previously opened divs
echo '<div class="row flush">'; //open div
}
echo '<img src="' . $img . '">';
$row++; // increase row counter.
}//end loop
echo '</div>';
}//end function
Make sure to put proper path into the tag