我想比較下面的2個數組,並找出差異。鍵「主人」和「公司」的值是不同的,但是當我比較這些數組時,它表示只有「公司」值是不同的。但是,當我創建2個只有一個鍵/值對「主人」的新陣列時,它可以正常工作。我犯了一些錯誤嗎?這個簡單的代碼有什麼問題?
<?php
$arr1 = Array
(
"leadid" => "418176000000069007",
"smownerid" => "418176000000047003",
"lead owner" => "Amit Patil",
"company" => "SAM",
"first name" => "Test",
"last name" =>"Lead1",
"designation" => "call",
"email" => "",
"phone" => "958",
"fax" => "",
"mobile" => "",
"website" => "www.infosys.con",
"lead source" => "Cold Call",
"lead status" => "Contact in Future",
"industry" => "None",
"no of employees" => "45000",
"annual revenue" => "0",
"rating" => "Active",
"smcreatorid" => "418176000000047003",
"created by" => "Amit Patil",
"modifiedby" => "418176000000047003",
"modified by" => "Amit Patil",
"created time" => "2012-04-05 19:58:00",
"modified time" => "2012-05-02 08:51:08",
"street" => "",
"city" => "",
"state" => "",
"zip code" => "",
"country" => "",
"description" => "",
"skype id" => "",
"email opt out" => "false",
"salutation" => "Mr.",
"secondary email" => ""
);
$arr2 = Array
(
"leadid" => "418176000000069007",
"smownerid" => "418176000000047003",
"lead owner" => "Amit aaa",
"company" => "SAM A",
"first name" => "Test",
"last name" => "Lead1",
"designation" => "call",
"email" => "",
"phone" => "958",
"fax" => "",
"mobile" => "",
"website" => "www.infosys.con",
"lead_source" => "Cold Call",
"lead_status" => "Contact in Future",
"industry" => "None",
"no_of_employees" => "45000",
"annual_revenue" => "0",
"rating" => "Active",
"smcreatorid" => "418176000000047003",
"created_by" => "Amit Patil",
"modifiedby" => "418176000000047003",
"modified_by" => "Amit Patil",
"created_time" => "2012-04-05 19:58:00",
"modified_time" => "2012-05-02 08:51:08",
"street" => "",
"city" => "",
"state" => "",
"zip_code" => "0",
"country" => "",
"description" => "",
"skype_id" => "",
"email_opt_out" => "false",
"salutation" => "Mr.",
"secondary_email" => ""
);
$arr3 = array("lead owner" => "Amit Patil");
$arr4 = array("lead owner" => "Amit aaa");
print_r(array_diff($arr1,$arr2));
echo "<br>";
print_r(array_diff($arr3,$arr4));
?>
輸出是如下
Array ([company] => SAM)
Array ([lead owner] => Amit Patil)
的輸出是什麼? – AlphaMale
添加了輸出。 –
也添加了你想要的輸出。意味着你想要的輸出是什麼? – AlphaMale