I have an array of albums $albums[]
and an array of photos $photos
. I want to echo out each album with all matching photos and am using this code:
<?php
...
foreach($albums as $album){
if( $album[photo_count] !== 0 ){
if($album[photo_count] > 10){
$limit = 10;
}
$boxID = $id = substr( $album[aid], strrpos( $album[aid], '_' )+1 );
?>
<div id="gal-<?=$boxID?>-box" class="box gallery-album">
<?
$i = 0;
foreach($photos as $photo){
if( ($photo[aid] == $album[aid]) && ($i < $limit) ){
echo '<img src="'.$photo[src_big].'" alt="'.$photo[caption].'"/>';
$i++;
}
}
?>
</div>
</div>
<?
}
}
This works fine, but feels very inefficient. Is there a better way of coding this?