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 7806159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:26:39+00:00 2026-06-02T02:26:39+00:00

I am having trouble trying to figure out how to get data ordered like

  • 0

I am having trouble trying to figure out how to get data ordered like below. The total numbers don’t matter; it would follow the same pattern from any number in the logical order of 0, 1, 2, 3, 4, 5, 6, etc. So essentially, starting at 0, 2, 3, 4, etc. where 1 would be placed after the maximum number, and where 0 can be a variable I set statically. I am having issues with progressing all the way to max number and then continuing, e.g.

..., 97, 98, 99, 100, 1, 2, ...

and then progressing with the order,

..., 98, 99, 100, 1, 2, 3, ...

and so on until 1, 2, 3, 4, 5, 6, …

and store this all into the multidimensional array below.

$set = array(
    array('0','0','0','0','0','0','0','0','0','0','0'),
    array('0','2','3','4','5','6','7','8','9','10','1'),
    array('0','3','4','5','6','7','8','9','10','1','2'),
    array('0','4','5','6','7','8','9','10','1','2','3'),
    array('0','5','6','7','8','9','10','1','2','3','4'),
    array('0','6','7','8','9','10','1','2','3','4','5'),
    array('0','7','8','9','10','1','2','3','4','5','6'),
    array('0','8','9','10','1','2','3','4','5','6','7'),
    array('0','9','10','1','2','3','4','5','6','7','8'),
    array('0','10','1','2','3','4','5','6','7','8','9'),
    array('0','1','2','3','4','5','6','7','8','9','10'),
); 

I did the above because I couldn’t figure out a looping pattern; if I could figure that out I wouldn’t need to enter in the data manually and could create a form by which any number could be chosen, following this pattern.

  • 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-02T02:26:40+00:00Added an answer on June 2, 2026 at 2:26 am

    Notice that other than the first row and column, each row is just the previous shifted left, with the next value added on:

    $max = 10;
    
    // First row (full of 0)
    $set = array(array_fill(0, $max + 1, 0));
    
    $row = array();
    for($i = 1; $i <= $max; $i++)
        $row[] = $i;
    $row[] = 1; // $row  = [2,3,4,...,$max,1]
    
    for($i = 0; $i < $max; $i++){
        $set[] = array_merge(array(0), $row);
        $row = array_map(function($x) use ($max){ // Requires PHP 5.3
            $result = ($x + 1) % $max;
            return 0 === $result ? $max : $result;
        }, $row);
    }
    

    Codepad

    It’s of course fairly trivial to make this store strings instead of integers if you require that.

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

Sidebar

Related Questions

I'm having trouble trying to figure out how to get prolog to spit out
I am having a bit of trouble trying to figure out how to get
I'm having a bit of a trouble trying to figure this out today, i
I'm having trouble trying to figure out why my formatDate is not working correctly.
I'm having trouble trying to figure out how to use a function contained in
having some trouble trying to figure this out, complete novice when it come to
I am having some trouble trying to figure this out. What i have is
I am having trouble trying to figure out how to use JQuery Autocomplete in
I am having some trouble trying to figure out the logic behind aligning the
I been having trouble trying to figure this out. When I think I have

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.