Match two arrays from a SOAP XML response in PHP

Mitja Bonca

New Member
I searched around the internet in the last 2 days and I didn't found any solution to my problem,I'm making a web application using PHP communicating with SOAP Web Services, and when I'm getting the respond of the Web Service I output the result in a few arrays, so now I want to match 1 array to another,for example, I have array \[code\]$company\[/code\] containing a list of 5 company locations, and then I have another array \[code\]$rates\[/code\] containing a list of 37 rates and prices but I have to match each price in which location it belongs to, and I don't know how to do that.I'm sorry for the long example I tried to make the shortest that I can, but I want you should understand what I mean\[code\] 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 ) ) ) ) ) ) ) ) )\[/code\]If you understand that you can see there is two type of arrays the first 3 is the location and the second is the cars with price, and I have to put each car to the correct location.If you need more explanation please tell me.Please help me out with that,Thank you.
 
Back
Top