$dict = array('key1' => 'value1', 'key2' => 'value2');
if(isset($dict['key1'])) {
// key1存在
} else {
// key1不存在
}
$dict = array('key1' => 'value1', 'key2' => 'value2');
if(array_key_exists('key1', $dict)) {
// key1存在
} else {
// key1不存在
}
$dict = array('key1' => 'value1', 'key2' => 'value2');
unset($dict['key1']);
// 現在$dict中只剩下'key2' => 'value2'
$dict1 = array('key1' => 'value1');
$dict2 = array('key2' => 'value2');
$merged_dict = array_merge($dict1, $dict2);
// $merged_dict現在為array('key1' => 'value1', 'key2' => 'value2')
$dict = array('key1' => 'value1', 'key2' => 'value2');
$keys = array_keys($dict);
// $keys為array('key1', 'key2')
$dict = array('key1' => 'value1', 'key2' => 'value2');
$values = array_values($dict);
// $values為array('value1', 'value2')