Home  >  Article  >  Backend Development  >  How to redefine the keys of the array?

How to redefine the keys of the array?

WBOY
WBOYOriginal
2016-12-01 00:57:031098browse

$arr = array( [8]=>123 , [0]=>888 );

Just turn it into array([0]=>123, [1]=>888) without changing the order;

Reply content:

$arr = array( [8]=>123 , [0]=>888 );

Just turn it into array([0]=>123, [1]=>888) without changing the order;

array array_values ​​(array $input)

Return all values ​​in the input array and index them numerically.

<code class="php">$arr = array( [8]=>123 , [0]=>888 );
var_dump(array_values($arr));
//output array( [0]=>123 , [1]=>888 )</code>

From php official manual
http://php.net/manual/zh/book...

array_merge($arr)Same

Array reordering shuffle()

<code>$a =  array('8'=>123,'0'=>888 );
shuffle ($a);
var_dump($a);
</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn