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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:42:28+00:00 2026-06-13T12:42:28+00:00

Is it possible to do something like the following in PHO I return an

  • 0

Is it possible to do something like the following in PHO

I return an array from my DB that looks like the following

1, 2 ,3 now i want to add a forth number to it and then resort them so

1 becomes 5
2 becomes 1
3 becomes 2
Fourth Number becomes 3

or is there a away to rearrange my table so it rotates. What i am trying to do is rotate and return a row in the database in order but once it has been returned i want to my page i want to get a user to enter another row into my database and then put the row that had been returned to the end so it would have the highest value.

I am basically updating my column by subtracting one from all entries and increaseing my first entry to the highest number

a. 1,2,3
b. 4,1,2,3
c. 3,5,1,2,4
d. 2,4,6,1,3,5

Hmmmm I dont think what i am saying is exacty what i am looking for or maybe someone understands what i am trying to say so i wont change it.

Or if i could use a auto incremented key starting at 1 and just rearrange all the data in the other columns would work.

So do this
1. Count the number of row
2. Return an array with all database table entries
2. Add a new entry to the database on the last row.
3. Move the entry in 1 to the number of rows +1 (creating a new row
4. Move all other entries up one.

so here is is

1 -> a
2 -> b
3 -> c

after adding another row

1 -> b
2 -> c
3 -> d
4 -> a

After adding another row

1 -> c 
2 -> d 
3 -> a 
4 -> e
5 -> b 

After adding another row

1 -> d
2 -> a
3 -> e
4 -> b
5 -> f
5 -> c

After adding another row

1 -> a
2 -> e
3 -> b
4 -> f
5 -> c
5 -> g
5 -> d

WHO can come up with a solution for me?????

  • 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-13T12:42:29+00:00Added an answer on June 13, 2026 at 12:42 pm

    You can use the below function and pass the shifting parameter to it. The function name is rotate_array() below. After using the function add the next value.

    <?php
    
    $weekdays = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
    
    function rotate_array($steps, $arr)
    {
        if($steps >= 0)
        {
            for($i = 0; $i < $steps; $i++)
            {
                $elm = array_shift($arr);
                array_push($arr, $elm);
            }
        }
        else
        {
            for($i = 0; $i > $steps; $i--)
            {
                $elm = array_pop($arr);
                array_unshift($arr, $elm);
            }
        }
        return $arr;
    }
    
    $arr = rotate_array(1, $weekdays);
    
    //For multidimensional array, add this part
    
    foreach($arr as $key => $childArray) {
    
           rotate_array(1,$childArray);
    
    
    }
    //end of addition
    
    $arr[] = "next value";
    echo "<pre>";
    print_r($arr);
    echo "</pre>";
    
    
    ?>
    

    Output:

    Array
    (
        [0] => Tue
        [1] => Wed
        [2] => Thu
        [3] => Fri
        [4] => Sat
        [5] => Sun
        [6] => Mon
        [7] => next value
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want something like the following: foo.should_receive(:bar).with(an_instance_of(Bla))..... Is this possible? Edit: According to the
I want to do something like the following in VB.NET, is it possible? Function
I have an svn repo that looks something like the following: TRUNK/ trials/ <-
is it possible to do something like the following in MySQL: SELECT * FROM
I have a header file that looks something like the following: class Model {
is it possible to do something like the following in ASP.NET: <tr<%= index++ %
is it possible to do something like the following: struct test { this {
Is it possible to do something like the following in jQuery: if($('UploadField').val().contains('.gif','.jpeg','.jpg','.png')) { }
Would it be possible to do something like the following in c#? Basically TParent
Is it possible in C# to something like the following foreach (ref string var

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.