我有两个
数组 $key = array(
"site_url" => "Site URL",
"current_date" => "Current Date",
"user_name" => "User name",
"name" => "Name of the user",
"password" => "Password of user",
"user_email" => "Email address of new user"
);
$tmpl_name = array ("name","url","current_date","email");
我想检查第一个数组的键值中是否存在第二个数组值。如果没有,则显示哪一个与第一个数组不同。
答案 0 :(得分:0)
$response->DoExpressCheckoutPaymentResponseDetails->PaymentInfo->SellerDetails->PayPalAccountID
与array_diff
相结合即可。试试这个:
array_keys
输出为:
$missing = array_diff($tmpl_name, array_keys($key));
或者你可以交换它们:
array(2) {
[1] = string(3) "url"
[3] = string(5) "email"
}
获取第一个数组中不在第二个值中的键。
$missing = array_diff(array_keys($key), $tmpl_name);