103.236.69.9:58721
administrator
GU87vqmdCb7Y
<?php
$contracts = [
"张三" => "13812345678",
"李四" => "18987654321",
"王五" => "13698765432",
"赵六" => "18876543210"
];
function add_contract($mingzi, $shouji, $contacts) {
if (!is_numeric($shouji)) {
echo "手机号码非法
";
return $contacts;
}
$contacts[$mingzi] = $shouji;
return $contacts;
}
function delete_contract($mingzi, $shouji, $contacts) {
if (!isset($contacts[$mingzi]) || $contacts[$mingzi] != $shouji) {
echo "用户不存在
";
return $contacts;
}
unset($contacts[$mingzi]);
return $contacts;
}
function edit_contract($mingzi, $newshouji, &$contacts) {
if (!isset($contacts[$mingzi])) {
echo "用户名不存在
";
return $contacts;
}
if (!is_numeric($newshouji)) {
echo "手机号非法
";
return $contacts;
}
$contacts[$mingzi] = $newshouji;
return $contacts;
}
$contracts = add_contract("甘癸源", "20240403192",$contracts);
$contracts = add_contract("测试", "abcdef", $contracts);
$contracts = edit_contract("王五", "abcdefg", $contracts);
$contracts = edit_contract("李七", "13133333333", $contracts);
$contracts = edit_contract("王五", "18888888888", $contracts);
$contracts = delete_contract("李七", "13133333333", $contracts);
$contracts = delete_contract("赵六", "18876543210", $contracts);
var_dump($contracts);
?>
您必须登录或注册以后才能发表评论