前两天在网上搜了一下,没有找到解决问题的办法,
我正在制作一个使用 PHP 与 SOAP Web 服务通信的 Web 应用程序,当我得到 Web 服务的响应时,我将结果输出到几个数组中,所以现在我想将 1 个数组与另一个数组匹配,
例如,我有$company
一个包含 5 个公司位置列表的数组,然后我有另一个$rates
包含 37 个价格和价格列表的数组,但我必须匹配它所属位置的每个价格,我不知道如何去做。
很抱歉,我试图尽可能缩短这个冗长的例子,但我希望你能理解我的意思
Array
(
[0] => SimpleXMLElement Object
(
[Car_AvailabilityReply] => SimpleXMLElement Object
(
[availabilityDetails] => SimpleXMLElement Object
(
[computeMarkups] => SimpleXMLElement Object
(
[actionRequestCode] => N
)
[rateClass] => SimpleXMLElement Object
(
[criteriaSetType] => COR
)
[companyLocationInfo] => Array
(
[0] => SimpleXMLElement Object
(
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[rentalLocation] => SimpleXMLElement Object
(
[address] => SimpleXMLElement Object
(
[addressDetails] => SimpleXMLElement Object
(
[line1] => 420 EAST 90TH STREET
)
[locationDetails] => SimpleXMLElement Object
(
[name] => NYCC07
)
)
)
)
[1] => SimpleXMLElement Object
(
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[rentalLocation] => SimpleXMLElement Object
(
[address] => SimpleXMLElement Object
(
[addressDetails] => SimpleXMLElement Object
(
[line1] => 310 EAST 64TH STREET
)
[locationDetails] => SimpleXMLElement Object
(
[name] => NYCC06
)
)
)
)
[2] => SimpleXMLElement Object
(
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[rentalLocation] => SimpleXMLElement Object
(
[address] => SimpleXMLElement Object
(
[addressDetails] => SimpleXMLElement Object
(
[line1] => 68 EAST 11TH STREET
)
[locationDetails] => SimpleXMLElement Object
(
[name] => NYCC03
)
)
)
)
)
[rates] => Array
(
[0] => SimpleXMLElement Object
(
[vehicleTypeInfo] => SimpleXMLElement Object
(
[vehicleCharacteristic] => SimpleXMLElement Object
(
[vehicleRentalPrefType] => CCAR
)
)
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[pickupDropoffLocations] => Array
(
[0] => SimpleXMLElement Object
(
[locationType] => PUP
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC07
)
)
[1] => SimpleXMLElement Object
(
[locationType] => DOL
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC07
)
)
)
[rateDetailsInfo] => SimpleXMLElement Object
(
[tariffInfo] => Array
(
[0] => SimpleXMLElement Object
(
[rateAmount] => 83.99
[rateCurrency] => USD
)
[1] => SimpleXMLElement Object
(
[rateAmount] => 100.68
[rateCurrency] => USD
)
)
)
)
[1] => SimpleXMLElement Object
(
[vehicleTypeInfo] => SimpleXMLElement Object
(
[vehicleCharacteristic] => SimpleXMLElement Object
(
[vehicleRentalPrefType] => CCAR
)
)
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[pickupDropoffLocations] => Array
(
[0] => SimpleXMLElement Object
(
[locationType] => PUP
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC06
)
)
[1] => SimpleXMLElement Object
(
[locationType] => DOL
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC06
)
)
)
[rateDetailsInfo] => SimpleXMLElement Object
(
[tariffInfo] => Array
(
[0] => SimpleXMLElement Object
(
[rateAmount] => 83.99
[rateCurrency] => USD
)
[1] => SimpleXMLElement Object
(
[rateAmount] => 100.68
[rateCurrency] => USD
)
)
)
)
[2] => SimpleXMLElement Object
(
[vehicleTypeInfo] => SimpleXMLElement Object
(
[vehicleCharacteristic] => SimpleXMLElement Object
(
[vehicleRentalPrefType] => CCAR
)
)
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[pickupDropoffLocations] => Array
(
[0] => SimpleXMLElement Object
(
[locationType] => PUP
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC03
)
)
[1] => SimpleXMLElement Object
(
[locationType] => DOL
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC03
)
)
)
[rateDetailsInfo] => SimpleXMLElement Object
(
[tariffInfo] => Array
(
[0] => SimpleXMLElement Object
(
[rateAmount] => 83.99
[rateCurrency] => USD
)
[1] => SimpleXMLElement Object
(
[rateAmount] => 100.68
[rateCurrency] => USD
)
)
)
)
[3] => SimpleXMLElement Object
(
[vehicleTypeInfo] => SimpleXMLElement Object
(
[vehicleCharacteristic] => SimpleXMLElement Object
(
[vehicleRentalPrefType] => EDAR
)
)
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[pickupDropoffLocations] => Array
(
[0] => SimpleXMLElement Object
(
[locationType] => PUP
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC03
)
)
[1] => SimpleXMLElement Object
(
[locationType] => DOL
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC03
)
)
)
[rateDetailsInfo] => SimpleXMLElement Object
(
[tariffInfo] => Array
(
[0] => SimpleXMLElement Object
(
[rateAmount] => 83.99
[rateCurrency] => USD
)
[1] => SimpleXMLElement Object
(
[rateAmount] => 100.68
[rateCurrency] => USD
)
)
)
)
[4] => SimpleXMLElement Object
(
[vehicleTypeInfo] => SimpleXMLElement Object
(
[vehicleCharacteristic] => SimpleXMLElement Object
(
[vehicleRentalPrefType] => EDAR
)
)
[carCompanyData] => SimpleXMLElement Object
(
[companyName] => AVIS
)
[pickupDropoffLocations] => Array
(
[0] => SimpleXMLElement Object
(
[locationType] => PUP
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC06
)
)
[1] => SimpleXMLElement Object
(
[locationType] => DOL
[locationDescription] => SimpleXMLElement Object
(
[name] => NYCC06
)
)
)
[rateDetailsInfo] => SimpleXMLElement Object
(
[tariffInfo] => Array
(
[0] => SimpleXMLElement Object
(
[rateAmount] => 83.99
[rateCurrency] => USD
)
[1] => SimpleXMLElement Object
(
[rateAmount] => 100.68
[rateCurrency] => USD
)
)
)
)
)
)
)
)
)
如果你理解你可以看到有两种类型的数组,前 3 个是位置,第二个是有价格的汽车,我必须把每辆车放在正确的位置。
如果您需要更多解释,请告诉我。
请帮我解决这个问题,谢谢。