我有这个变量保存的数组:
$get_multiple_role_will_redirect = isset($_POST['multiple_role_will_redirect']) ? $_POST['multiple_role_will_redirect'] : 0;
Array
(
[Administrator] =>
[Editor] =>
[Author] =>
[Contributor] =>
[Subscriber] =>
[Shop_manager] =>
[Shop_accountant] =>
[Shop_worker] =>
[Shop_vendor] =>
[Edd_subscriber] =>
[Customer] =>
)
现在,我要小写所有键。为此,我正在像这样进行foreach:
$multiple_role_will_redirect = [];
foreach($get_multiple_role_will_redirect as $key => $value) {
$key = strtolower($key);
$multiple_role_will_redirect[$key] = $value;
}
我的问题是,是否有没有其他方法,而没有foreach
循环到小写数组key?
我已与:核对过]
array_filter($get_multiple_role_will_redirect, 'strtolower');
但是它不是小写的数组键。
我有一个由该变量保存的数组:$ get_multiple_role_will_redirect = isset($ _ POST ['multiple_role_will_redirect'])? $ _POST ['multiple_role_will_redirect']:0;数组([...
我认为array_change_key_case
函数适合您。