Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
I need to change my array index values from
Array ( [0] => 84 [1] => 109 [4] => 78 )
to
Array ( [1] => 84 [2] => 109 [3] => 78 )
Thank you.
Quick and dirty method
$arrayData = array_combine( range(1, count($arrayData)), $arrayData );
Add a comment
If you want to re-index starting to zero, simply do the following:
$ArrayFromZero = array_values($arr);
If you need it to start at one, then use the following:
$arrayFromOne = array_combine(range(1, count($arr)), array_values($arr));
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.