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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:29:53+00:00 2026-05-24T04:29:53+00:00

I have an array $matrix_part , containing arrays, and I want to rekey the

  • 0

I have an array $matrix_part, containing arrays, and I want to rekey the inner keys to start at 1.

I am trying to code below but it doesn’t work – it just stores the new array identically.

$temp_matrix = array();
foreach ($matrix_part as $k => $v){
$temp_matrix[$k++] = $v;
}
$matrix_part = $temp_matrix;

Source array:

Array
(
    [0] => Array
        (
            [0] => 163
            [1] => 23
            [2] => 97
        )
    [1] => Array
        (
            [0] => 163
            [1] => 23
            [2] => 97
        )
    [2] => Array
        (
            [0] => 163
            [1] => 23
            [2] => 97
        )
)

Desired output:

Array
(
    [0] => Array
        (
            [1] => 163
            [2] => 23
            [3] => 97
        )
    [1] => Array
        (
            [1] => 163
            [2] => 23
            [3] => 97
        )
    [2] => Array
        (
            [1] => 163
            [1] => 23
            [3] => 97
        )
)
  • 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-05-24T04:29:55+00:00Added an answer on May 24, 2026 at 4:29 am
    foreach ($a as $outer_k => $outer_v) {
        for ($i = count($outer_v) - 1; $i >= 0; $i--) {
            $outer_v[$i+1] = $outer_v[$i];
        }
        unset($outer_v[0]);
        $a[$outer_k] = $outer_v;
    }
    

    where $a is your input array

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

Sidebar

Related Questions

i have array unknown size i want to transfer to matrix[n][2].Example; D[c]=1,2,3,4,5 D[c/2][2]= 1
I have an array of hashes, many of which have shared keys. I would
I have an array of empty cells and ones that I want to convert
I am currently have a nx3 matrix array. I want plot the three columns
I have a 2d array (matrix) where I am trying to calculate the biggest
let's say I have a matrix (array) like this example, but much larger: 0
Suppose you have an array (m, m) and want to make it (n, n).
i have the following code and i am receiving the error size of array
I have an matrix (array of arrays) in the form [1, 2, 3, 4]
I have this code: $id = new matrix(array(0=>array(1,0.5,3), 1=>array(2,1,4), 2=>array(1/3,1/4,1))); $soma = $id->times($id)->sumRows(); That

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.