echo PHP array with while loop
<p>I'm using a while loop to echo a PHP array :</p>

<pre><code>$connect = mysqli_connect("localhost", "user", "password", "db");
$sql = "SELECT * FROM table ORDER BY RAND() LIMIT 0,4";
$result = mysqli_query($connect, $sql);

if(mysqli_num_rows($result) &gt; 0)
{
 echo'&lt;section&gt;
        &lt;div class="container"&gt;
           &lt;div class="row"&gt;
             &lt;h2 class="bold"&gt;title&lt;/h2&gt;
               &lt;hr&gt; ';

                while($row = mysqli_fetch_array($result))
                {
                 echo'
                &lt;div class="col-sm-3 col-md-3 col-md-push-3"&gt;
                    &lt;div class="portfolio-wrapper"&gt;   
                        &lt;div class="portfolio-single"&gt;
                            &lt;div class="portfolio-thumb"&gt;
                                &lt;a href="'.$row['link']." target="_blank"&gt;                                                        &lt;img src="'.$row['image'].'" class="img-responsive" alt="'.$row['alt']."&gt;&lt;/a&gt;
                            &lt;/div&gt;
                        &lt;/div&gt;
                        &lt;div class="portfolio-info" dir="rtl"&gt;
                            &lt;a href="'.$row['link2']." target="_self"&gt;&lt;h2&gt;                     &lt;/h2&gt;
                                &lt;h6&gt;'.$row['title'].&lt;/h6&gt;
                            &lt;/a&gt;
                        &lt;/div&gt;
                    &lt;/div&gt;
                &lt;/div&gt;';

            }
                echo'
                &lt;/div&gt;
                    &lt;/div&gt;
                    &lt;/section';
            }   

            ?&gt;
</code></pre>

<p>This code works fine for me but the problem is that i need to echo 4 different 
       </p>

<p>for example :</p>

<pre><code>   first will be: &lt;div class="col-sm-3 col-md-3 col-md-push-9"&gt;
   second: &lt;div class="col-sm-3 col-md-3 col-md-push-3"&gt;
   third: &lt;div class="col-sm-3 col-md-3 col-md-pull-3"&gt;
   last: &lt;div class="col-sm-3 col-md-3 col-md-pull-9"&gt;
</code></pre>

<p>any ideas how can i accomplish this structure using a while loop ?</p>