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.
As you index starts as 1 instead of 0, you need to use
rangefunction and with the help ofarray_combineyou get the resultant array.To make it more general you can use this,