PHP Convert Array Keys

前端 未结 4 1860
误落风尘
误落风尘 2021-02-03 23:44

Had a hard time wording this in google so I figure ill ask here.

I have an array like such:

Array ( [a] => \'a\' [b] => \'b\' [c] => \'c\' )


        
相关标签:
4条回答
  • 2021-02-04 00:14

    Use array_values(), as in the manual example:

    <?php
    $array = array("size" => "XL", "color" => "gold");
    print_r(array_values($array));
    

    The above example will output:

    Array
    (
        [0] => XL
        [1] => gold
    )
    
    0 讨论(0)
  • 2021-02-04 00:14
    $my_array = array( [a] => 'a' [b] => 'b' [c] => 'c' )
    $my_new_array = array_values($my_array);
    
    0 讨论(0)
  • 2021-02-04 00:24

    You want the array_values function.

    0 讨论(0)
  • 2021-02-04 00:34

    Try array_values

    $arrayWithNumericKeys = array_values($arrayWithRegularKeys);
    
    0 讨论(0)
提交回复
热议问题