php: Array keys case *insensitive* lookup?

前端 未结 12 1949
予麋鹿
予麋鹿 2020-12-25 10:30
$myArray = array (\'SOmeKeyNAme\' => 7);  

I want $myArray[\'somekeyname\'] to return 7.
Is there a way to do this

12条回答
  •  Happy的楠姐
    2020-12-25 11:11

    A simple, but maybe expensive way, is to make a copy, then use array_change_key_case($array_copy, CASE_LOWER), and after that access array_copy['somekeyname']

提交回复
热议问题