Echo自举网格与数组中的图片

I'm probably confusing myself more than is necessary with this.

I have 12 images on my server, and an array that handles their links.

$ppDefault = "images/profile/default/";
$ppDefaultArray = array($pLoc . "p-01.png", $pLoc . "p-02.png", $pLoc . "p-03.png", ...);

My goal is to have this structure:

<div class="row">
    <div class="col-md-3">
        <img class="img-responsive" src="image.png" />
    </div>
    <div class="col-md-3">
        <img class="img-responsive" src="image.png" />
    </div>
    <div class="col-md-3">
        <img class="img-responsive" src="image.png" />
    </div>
    <div class="col-md-3">
        <img class="img-responsive" src="image.png" />
    </div>
</div>
And so on with more rows and columns

Currently my php code is as follows:

<?php
    $count = 4;
    for ($i = 0; $i < count($ppDefaultArray); $i++) {
        if ($count % 4 == 0) {
            echo 
                '<div class="row">';
                for ($j = 0; $j < 4; $j++) {
                    echo '<div class="col-md-3"><img class="img-responsive" src="' . $ppDefaultArray[$i] . '"/></div>';
                }
                echo '</div>';
        } else {
            for ($j = 0; $j < 4; $j++) {
                echo '<div class="col-md-3"><img class="img-responsive" src="' . $ppDefaultArray[$i] . '"/></div>';
            }
        }
        $count++;
    }   
?>

Which outputs me something like this: enter image description here

Which is not what I need. I need each picture to only show up once and I'm assuming some tags are missing as some pictures are misaligned.

If desired I can post the resulting HTML created but it is quite large.

Try this

<?php

echo '<div class="row">';
for ($i = 0; $i < count($ppDefaultArray); $i++) {
    echo '<div class="col-md-3"><img class="img-responsive" src="' . $ppDefaultArray[$i] . '"/></div>';
    if (($i+1) % 4 == 0)
        echo '</div><div class="row">';
}   
echo '</div>';
?>

Might wanna try something like this:

<?php
$count = 4;

echo '<div class="row">';
for ($i = 0; $i < count($ppDefaultArray); $i++) {

    echo '<div class="col-md-3"><img class="img-responsive" src="' . $ppDefaultArray[$i] . '"/></div>';

    if ($count % 4 == 0) { // time to break line
        echo '</div>';
        echo '<div class="row">';
    } 

    $count++;
}   
echo '</div>';

Here is my suggestion

<?php
$imgeIndex = 0;
while($imgeIndex < count($ppDefaultArray)){
    echo '<div class="row">';
    for ($col = 0; $col < 4; $col++) {
        echo '<div class="col-md-3"><img class="img-responsive" src="' $ppDefaultArray[$imgeIndex] . '"/></div>';
        $imgeIndex++;
    }
    echo '</div>';
}

?>

First initialize $cont = 4.5 if you want four columns each row

@foreach ($images as $image )

    @if($count==0  OR is_int($count/3))
        <?php echo '<div class="row">';?>
     @endif

    <div class="col-md-3">
      <div class="well" style="background:white;">
        <img src="{{ url('images/'.$image->filepath) }}" alt="" class="" height="100" width="100" ></br>

       {{ $image->title }}<br>
        {{$image->filepath }}
      </div>
    </div>

    @if($count==0 OR is_int($count/3))
        <?php echo '</div>' ;?>

    @endif

    <?php $count++;?>
@endforeach