Welcome Guest, Not a member yet? Register   Sign In
[Solved] New row every 6 image php loop
#1

(This post was last modified: 12-27-2016, 04:01 AM by wolfgang1983.)

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;

There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply
#2

(This post was last modified: 12-27-2016, 04:06 AM by wolfgang1983.)

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]
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB