After deleting an element in the php array, you can re-index the element. Does the php array provide a re-indexing method after deleting an element? $ Tmp = array (1, 2, 3); unset ($ tmp [& quot; 1 & quot;]); echo & quot; & lt; pre & gt; & quot ;; print_r ($ tmp); run the php array to delete elements and re-index them.
Does the php array provide a re-indexing method after deleting an element?
$ Tmp = array (1, 2, 3 );
Unset ($ tmp ["1"]);
Echo"
";
Print_r ($ tmp );
Running result:
Array
(
[0] => 1
[2] => 3
)
The result I need is:
Array
(
[0] => 1
[1] => 3
)
Does php provide this function for re-indexing? thank you!
------ Solution --------------------
Array_values ()
------ Solution --------------------
Print_r (array_values ($ tmp ));
------ Solution --------------------
The array_values () function returns an array containing all the key values in the given array without retaining the key name.