如果数组等于数组PHP

如果数组等于数组PHP,php,arrays,Php,Arrays,如果($array1[0]=>somevalue==$array2[0]=>somevalue){echo true;}其他{echo false;},是否可以使?因为我做不到,你能帮我吗 例如: $array1([0]=>Joe',[2]=>Pairs'); $array2([0]=>info'=>array([0]=>joe') 这是真正的代码 阵列: Array ( [0] => SimpleXMLElement Object ( [companyLocat

如果($array1[0]=>somevalue==$array2[0]=>somevalue){echo true;}其他{echo false;},是否可以使
?因为我做不到,你能帮我吗

例如: $array1([0]=>Joe',[2]=>Pairs'); $array2([0]=>info'=>array([0]=>joe')

这是真正的代码

阵列:

 Array
(
[0] => SimpleXMLElement Object
    (
        [companyLocationInfo] => Array
            (
                [0] => SimpleXMLElement Object
                    (
                        [companyName] => AVIS
                        [name] => NYCC07
                        [line1] => 420 EAST 90TH STREET
                    )
                [2] => SimpleXMLElement Object
                    (
                        [companyName] => AVIS
                        [name] => NYCC06
                        [line1] => 310 EAST 64TH STREET
                    )
                [3] => SimpleXMLElement Object
                    (
                        [companyName] => AVIS
                        [name] => NYCC01
                        [line1] => 68 EAST 11TH STREET
                    )

            )

        [rates] => Array
            (
                [0] => SimpleXMLElement Object
                    (
                        [pickupDropoffLocations] => Array
                            (
                                [0] => SimpleXMLElement Object
                                    (
                                        [companyName] => AVIS
                                        [name] => NYCC07
                                    )
                            )
                        [vehicleRentalPrefType] => CCAR
                        [rateAmount] => 83.99
                        [rateCurrency] => USD
                    )
                [2] => SimpleXMLElement Object
                    (
                        [pickupDropoffLocations] => Array
                            (
                                [0] => SimpleXMLElement Object
                                    (
                                        [companyName] => AVIS
                                        [name] => NYCC06
                                    )
                            )
                        [vehicleRentalPrefType] => CCAR
                        [rateAmount] => 110.54
                        [rateCurrency] => USD
                    )
                [3] => SimpleXMLElement Object
                    (
                        [pickupDropoffLocations] => Array
                            (
                                [0] => SimpleXMLElement Object
                                    (
                                        [companyName] => AVIS
                                        [name] => NYCC01
                                    )
                            )
                        [vehicleRentalPrefType] => CCAR
                        [rateAmount] => 210.65
                        [rateCurrency] => USD
                    )

            )

    )
)

这是代码:

$results_array = array();

foreach($result[0]->rates as $rate) {
    foreach($result[0]->companyLocationInfo as $info) {
        if($info->name == $rate->pickupDropoffLocations[0]->name) {
            $results_array[] = array(
                'line1' => $info->line1,
                'name' => $info->locationDetails->name,
                'companyName' => $info->companyName,
                'vehicleRentalPrefType' => $rate->vehicleRentalPrefType
            );
        }
    }
}
print_r($results_array);

谢谢。

你想做的应该是可能的。如果上面的代码是您实际尝试运行的代码,那么您的第一个问题是您正在比较值
“Joe”
“Joe”
,而这些值并不相同


如果需要不区分大小写的比较,请使用
If(strcasecmp($var1,$var2)==0)
(如果两个字符串相同,则返回零,不考虑大小写)

这个问题和XML或SOAP有什么关系?因为我的代码是用SimpleXML编写的
$results_array = array();

foreach($result[0]->rates as $rate) {
    foreach($result[0]->companyLocationInfo as $info) {
        if($info->name == $rate->pickupDropoffLocations[0]->name) {
            $results_array[] = array(
                'line1' => $info->line1,
                'name' => $info->locationDetails->name,
                'companyName' => $info->companyName,
                'vehicleRentalPrefType' => $rate->vehicleRentalPrefType
            );
        }
    }
}
print_r($results_array);