PHP - Get key name of array value

前端 未结 9 1548
暗喜
暗喜 2020-11-29 16:53

I have an array as the following:

function example() {
    /* some stuff here that pushes items with
        dynamically created key strings into an array */         


        
9条回答
  •  北海茫月
    2020-11-29 17:37

    use array_keys() to get an array of all the unique keys.

    Note that an array with named keys like your $arr can also be accessed with numeric indexes, like $arr[0].

    http://php.net/manual/en/function.array-keys.php

提交回复
热议问题