Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8264883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:36:52+00:00 2026-06-08T04:36:52+00:00

i have for example: <?php $array = array(aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj,kkk,lll,mmm,nnn, 111,222,333); ?> and if i use

  • 0

i have for example:

<?php $array = array(aaa,bbb,ccc,ddd,eee,fff,ggg,hhh,iii,jjj,kkk,lll,mmm,nnn, 111,222,333); ?>

and if i use foreach:

foreach($array as $a){
  echo $a . '<br />';
}

this show me data:

aaa
bbb
ccc
ddd
eee
fff
...
111
222
333

but i would like set max positions in height – and if for example data is too long then this should be in new column:

aaa eee ... 111
bbb fff ... 222
ccc ... ... 333

How is the best way for this? I can use DIV or TABLE.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T04:36:53+00:00Added an answer on June 8, 2026 at 4:36 am

    You will need to add a counter in your php, where it creates a new div element for each three elements and float all the div elements to the left.

    PHP:

    $array = array("aaa","bbb","ccc","ddd","eee","fff","ggg","hhh","iii","jjj","kkk","lll","mmm","nnn", "111","222","333");
    
    $index = 0;
    foreach($array as $a){
      $index = $index + 1;
      if ($index % 3 === 1){
          echo '<div class="column">';
      }
      echo $a . '<br />';
      if ($index % 3 === 0){
          echo '</div>';
      }
    }
    if ($index % 3 !== 0){
          echo '</div>';
    }
    

    and in your CSS, you will need:

    .column{
      float:left;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP array which looks like this example: $array[0][0] = 'apples'; $array[0][1]
Tech used: PHP 5.3.10 Hi, I have an array (example below) I need to
For example I have a PHP array, such as this one <?php $s= array('a','b','c','d','e','f')
I have pairs of items in an PHP array. Example: <?php $elements = array(
I have an array of arrays in PHP in this layout for example, Key1
I have example language file en.php <?php $language = array( language_code => en, language_name
Suppose I have a example.php file like that: <p> <?php echo _('Hello world') ?>
I have looked at this example using php and GD to piecewise-render a spiral
I have this code (an example that PHP generates for me)... <select id=outsideBlue3> <option
I have got two pages. example.com/php.com and example.com. I use this function to set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.