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

  • SEARCH
  • Home
  • 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 8549281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:41:18+00:00 2026-06-11T13:41:18+00:00

$random = rand(4, 23); $range = range(1, $random ); HI.. guys I have a

  • 0
$random = rand(4, 23);
$range = range(1, $random );

HI.. guys
I have a random range value here in foreach function i want to display with below
rules.. my aim is to display like a square box

if i get range 1 to 3 it has to display table like this

1 2
3

if range from 1 to 6

1 2 3
4 5 6

if range from 1 to 19

1   2  3  4  5
6   7  8  9 10
11 12 13 14 15
16 17 18 19
  • 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-11T13:41:18+00:00Added an answer on June 11, 2026 at 1:41 pm

    get the ceil of the square root of the number of records, and then anytime you’re at an index with a mod of that value that is equal to 0, start a new line. Since you already have $random something like:

    $dim = ceil(sqrt($random));
    
    foreach ($range as $index => $number) {
        print $number;
        if (!(($index + 1) % $dim)) {
          print "\n";
        }
        else {
          print " ";
        }
    }
    

    May need some adjustment (I’m not in PHP mode atm) and also doesn’t factor in the padding but that should be straightforward.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to generate a bunch of random numbers using rand() % (range). Here's
We know that the classic range random function is like this: public static final
Does SQLite support seeding the RANDOM() function the same way MySQL does with RAND()
This is my function: Random(int min, int max) { srand(time(NULL)); return (rand() % (max-min))
I have a very basic random number function which generates a random number from
I am using below code to generate random numbers in range... int randomNumberWithinRange(int min,int
i want to generate an array of random numbers for example if the range
I would like to make random numbers in a specific range, like pick a
I want to generate random numbers in the range -1, 1 and want each
I want to call 'int Random::random(int lower, int upper) function, however I get a

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.