Reset PHP Array Index

后端 未结 3 564
别跟我提以往
别跟我提以往 2020-12-04 10:52

I have a PHP array that looks like this:

[3] => Hello
[7] => Moo
[45] => America

What PHP function makes this?

[0]         


        
3条回答
  •  一生所求
    2020-12-04 11:07

    If you want to reset the key count of the array for some reason;

    $array1 = [
      [3]  => 'Hello',
      [7]  => 'Moo',
      [45] => 'America'
    ];
    $array1 = array_merge($array1);
    print_r($array1);
    

    Output:

    Array(
      [0] => 'Hello',
      [1] => 'Moo',
      [2] => 'America'
    )
    

提交回复
热议问题