是的,array_key_exists() 函数可以检查字符串是否存在于数组中
<?php
$array = array("key1" => "value1", "key2" => "value2", "key3" => "value3");
$key = "key2";
if (array_key_exists($key, $array)) {
echo "The key '$key' exists in the array.";
} else {
echo "The key '$key' does not exist in the array.";
}
?>
在这个例子中,array_key_exists() 函数检查 $key 是否存在于 $array 中。如果存在,它将输出 “The key ‘key2’ exists in the array.”,否则输出 “The key ‘key2’ does not exist in the array.”。