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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:13:41+00:00 2026-06-17T16:13:41+00:00

I have array with data and key [1, 2, 4, 5]. $array = xxxx;

  • 0

I have array with data and key [1, 2, 4, 5].

$array = xxxx;

this is:

                       [array] => Array
                            (
                                [1] => Array
                                    (
                                        [test] => fdasdfs24
                                    )

                                [2] => Array
                                    (
                                        [test] => fdasdf23
                                    )

                                [4] => Array
                                    (
                                        [test] => fdasdf4
                                    )

                                [5] => Array
                                    (
                                        [test] => fdasdf34
                                    )

                            )

How can i reset indexes in this and array? I would like receive: [1, 2, 3, 4]

                       [array] => Array
                            (
                                [1] => Array
                                    (
                                        [test] => fdasdfs24
                                    )

                                [2] => Array
                                    (
                                        [test] => fdasdf23
                                    )

                                [3] => Array
                                    (
                                        [test] => fdasdf4
                                    )

                                [4] => Array
                                    (
                                        [test] => fdasdf34
                                    )

                            )

how can i make it? Maybe is for this some function? I dont want doing this mannually – this is only example.

  • 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-17T16:13:41+00:00Added an answer on June 17, 2026 at 4:13 pm

    As you index starts as 1 instead of 0, you need to use range function and with the help of array_combine you get the resultant array.

    array_combine(range(1,4),  array_values($array));
    

    To make it more general you can use this,

    array_combine(range(1,count($array)),  array_values($array));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have array that I can display by code: foreach($form->data as $key => $value){
This is not the explode can solve I have several array $order data: {5,3,2}
I have this array Array ( [data] => Array ( [0] => Array (
I have a long array of data ( n entities). Every object in this
I have an array, $data, that looks like this when printed: [1] => Array
how can i rename key value in python? i have this code : t
I have this array Array ( [data] => Array ( [0] => Array (
I have tried to pass array data to the PHP script with request: script.php?page=7&filter[key]=value
I have an array holding this data: Array ( [1402377] => 7 [1562441] =>
I can't deal with this. Please help me. This is array: $arr = array(data

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.