CodeIgniter Forums

Full Version: [Solved] New row every 6 image php loop
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
On my function below I am trying to make it so for every 6 smiley images gentenrated it will create a new row

I have added bootstrap columns in $link[] but need to be able to create a new row every 6 images

Question how to create a new row every 6 images in function below


PHP Code:
function get_clickable_smileys($image_url$alias '') {
    
    
// For backward compatibility with js_insert_smiley
    if (is_array($alias))
    {
        $smileys $alias;
    }
    
    elseif 
(FALSE === ($smileys _get_smiley_array()))
    
    
{
        return FALSE;
        
    
}

    // Add a trailing slash to the file path if needed
    
    $image_url 
rtrim($image_url'/').'/';

    $used = array();

    foreach ($smileys as $key => $val)
    {
        if (isset($used[$smileys[$key][0]]))
        {
            continue;
        }

        $link[] = '<div class="col-lg-4"><a data-toggle="tooltip" data-placement="top" title="'.$smileys[$key][3].'" href="javascript:void(0);" onclick="insert_smiley(\''.$key.'\', \''.$alias.'\')"><img src="'.$image_url.$smileys[$key][0].'" alt="'.$smileys[$key][3].'" class="img-thumbnail" width="100%;" height="'.$smileys[$key][2].'px;" /></a></div>';
        
        $used
[$smileys[$key][0]] = TRUE;
    }

    return $link;

Found this way works on view I have updated all smile images


PHP Code:
 <div class="modal-body">
        <?php echo smiley_js();?>
        
        <?php 

         
foreach(array_chunk($smiley_table6) as $entriesRow) {
             echo '<div class="row" style="margin-bottom: 20px;">';
                 foreach ($entriesRow as $entry) {
                     echo "<div class='col-md-4'>$entry</div>";
                 }
             echo '</div>';
         }
            

        ?>
      </div> 




[Image: 36oKpOVtE8Zl.png]