PHP - Get key name of array value

前端 未结 9 1432
暗喜
暗喜 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:46

    Here is another option

    $array = [1=>'one', 2=>'two', 3=>'there'];
    $array = array_flip($array);
    echo $array['one']; 
    

提交回复
热议问题