19/03/2009, 09:40
|
| | | Fecha de Ingreso: marzo-2009 Ubicación: Málaga (España)
Mensajes: 10
Antigüedad: 15 años, 8 meses Puntos: 0 | |
Respuesta: Petición SOAP por HTTP Ya conseguí parsear uno delo chorizos grandes:
array(1) { ["JP_ZoneListRS"]=> array(1) { ["Zone"]=> array(38) { [0]=> array(4) { ["!Code"]=> string(5) "37356" ["!Name"]=> string(7) "Andorra" ["!Parent"]=> string(0) "" ["!IATA"]=> string(2) "AD" } [1]=> array(4) { ["!Code"]=> string(5) "17605" ["!Name"]=> string(6) "Brasil" ["!Parent"]=> string(0) "" ["!IATA"]=> string(3) "BR " } [2]=> array(4) { ["!Code"]=> string(5) "17613" ["!Name"]=> string(7) "Canadá" ["!Parent"]=> string(0) "" ["!IATA"]=> string(3) "CA " } [3]=> array(4) { ["!Code"]=> string(5) "36560" ["!Name"]=> string(23) "Emiratos Árabes Unidos" ["!Parent"]=> string(0) "" ["!IATA"]=> string(2) "AE" } [4]=> array(4) { ["!Code"]=> string(5) "17748" ["!Name"]=> string(7) "España" ["!Parent"]=> string(0) "" ["!IATA"]=> string(2) "ES" } [5]=> array(4) { ["!Code"]=> string(5) "17647" ["!Name"]=> string(7) "Francia" ["!Parent"]=> string(0) "" ["!IATA"]=> string(3) "FR " } [6]=> array(4) { ["!Code"]=> string(5) "17700" ["!Name"]=> string(7) "México" ["!Parent"]=> string(0) "" ["!IATA"]=> string(3) "MX " } [7]=> array(4) { ["!Code"]=> string(5) "17729" ["!Name"]=> string(8) "Portugal" ["!Parent"]=> string(0) "" ["!IATA"]=> string(3) "PT " } [8]=> array(4) { ["!Code"]=> string(5) "17784" ["!Name"]=> string(11) "Reino Unido" ["!Parent"]=> string(0) "" ["!IATA"]=> string(3) "GB " } [9]=> array(4) { ["!Code"]=> string(5) "36609" ["!Name"]=> string(7) "Ucrania" ["!Parent"]=> string(0) "" ["!IATA"]=> string(2) "UA" } [10]=> array(4) { ["!Code"]=> string(5) "17785" ["!Name"]=> string(3) "Usa" ["!Parent"]=> string(0) "" ["!IATA"]=> string(3) "US " } [11]=> array(4) { ["!Code"]=> string(5) "35386" ["!Name"]=> string(17) "Barcelona Región" ["!Parent"]=> string(5) "17748" ["!IATA"]=> string(0) "" } [12]=> array(4) { ["!Code"]=> string(5) "26639" ["!Name"]=> string(8) "Colorado" ["!Parent"]=> string(5) "17785" ["!IATA"]=> string(0) "" } [13]=> array(4) { ["!Code"]=> string(5) "36501" ["!Name"]=> string(11) "Costa Brava" ["!Parent"]=> string(5) "17748" ["!IATA"]=> string(0) "" } [14]=> array(4) { ["!Code"]=> string(5) "36773" ["!Name"]=> string(5) "Dubai" ["!Parent"]=> string(5) "36560" ["!IATA"]=> string(3) "DXB" } [15]=> array(4) { ["!Code"]=> string(5) "35311" ["!Name"]=> string(7) "Florida" ["!Parent"]=> string(5) "17785" ["!IATA"]=> string(0) "" } [16]=> array(4) { ["!Code"]=> string(5) "38364" ["!Name"]=> string(20) "Governador Valadares" ["!Parent"]=> string(5) "17605" ["!IATA"]=> string(3) "GVR" } [17]=> array(4) { ["!Code"]=> string(5) "47386" ["!Name"]=> string(10) "Inglaterra" ["!Parent"]=> string(5) "17784" ["!IATA"]=> string(0) "" } [18]=> array(4) { ["!Code"]=> string(5) "41765" ["!Name"]=> string(14) "Islas Baleares" ["!Parent"]=> string(5) "17748" ["!IATA"]=> string(0) "" } [19]=> array(4) { ["!Code"]=> string(5) "36916" ["!Name"]=> string(4) "Kiev" ["!Parent"]=> string(5) "36609" ["!IATA"]=> string(3) "IEV" } [20]=> array(4) { ["!Code"]=> string(5) "33448" ["!Name"]=> string(22) "Lisboa (Y Alrededores)" ["!Parent"]=> string(5) "17729" ["!IATA"]=> string(3) "LIS" } [21]=> array(4) { ["!Code"]=> string(5) "35315" ["!Name"]=> string(6) "Nevada" ["!Parent"]=> string(5) "17785" ["!IATA"]=> string(0) "" } [22]=> array(4) { ["!Code"]=> string(5) "19109" ["!Name"]=> string(5) "Paris" ["!Parent"]=> string(5) "17647" ["!IATA"]=> string(3) "PAR" } [23]=> array(4) { ["!Code"]=> string(5) "38695" ["!Name"]=> string(10) "Pontevedra" ["!Parent"]=> string(5) "17748" ["!IATA"]=> string(0) "" } [24]=> array(4) { ["!Code"]=> string(5) "35301" ["!Name"]=> string(12) "Quintana Roo" ["!Parent"]=> string(5) "17700" ["!IATA"]=> string(0) "" } [25]=> array(4) { ["!Code"]=> string(5) "36259" ["!Name"]=> string(8) "Salvador" ["!Parent"]=> string(5) "17605" ["!IATA"]=> string(3) "SSA" } [26]=> array(4) { ["!Code"]=> string(5) "18812" ["!Name"]=> string(7) "Toronto" ["!Parent"]=> string(5) "17613" ["!IATA"]=> string(3) "YTO" } [27]=> array(4) { ["!Code"]=> string(5) "18775" ["!Name"]=> string(9) "Vancouver" ["!Parent"]=> string(5) "17613" ["!IATA"]=> string(3) "YVR" } [28]=> array(4) { ["!Code"]=> string(5) "25720" ["!Name"]=> string(5) "Aspen" ["!Parent"]=> string(5) "26639" ["!IATA"]=> string(3) "ASE" } [29]=> array(4) { ["!Code"]=> string(5) "41641" ["!Name"]=> string(16) "Barcelona Ciudad" ["!Parent"]=> string(5) "35386" ["!IATA"]=> string(3) "BCN" } [30]=> array(4) { ["!Code"]=> string(5) "22520" ["!Name"]=> string(7) "Cancún" ["!Parent"]=> string(5) "35301" ["!IATA"]=> string(3) "CUN" } [31]=> array(4) { ["!Code"]=> string(5) "26739" ["!Name"]=> string(9) "Las Vegas" ["!Parent"]=> string(5) "35315" ["!IATA"]=> string(3) "LAS" } [32]=> array(4) { ["!Code"]=> string(5) "45369" ["!Name"]=> string(13) "Lisboa Ciudad" ["!Parent"]=> string(5) "33448" ["!IATA"]=> string(3) "LIS" } [33]=> array(4) { ["!Code"]=> string(5) "35417" ["!Name"]=> string(21) "Londres Y Alrededores" ["!Parent"]=> string(5) "47386" ["!IATA"]=> string(3) "LON" } [34]=> array(4) { ["!Code"]=> string(5) "17852" ["!Name"]=> string(8) "Mallorca" ["!Parent"]=> string(5) "41765" ["!IATA"]=> string(0) "" } [35]=> array(4) { ["!Code"]=> string(5) "35424" ["!Name"]=> string(5) "Miami" ["!Parent"]=> string(5) "35311" ["!IATA"]=> string(3) "MIA" } [36]=> array(4) { ["!Code"]=> string(5) "26060" ["!Name"]=> string(7) "Orlando" ["!Parent"]=> string(5) "35311" ["!IATA"]=> string(3) "ORL" } [37]=> array(4) { ["!Code"]=> string(5) "41770" ["!Name"]=> string(20) "Barcelona Aeropuerto" ["!Parent"]=> string(5) "41641" ["!IATA"]=> string(3) "BCN" } } } }
son arrays multidimensionales... este primero fue facil de parsear con un foreach anidado:
foreach($result['JP_ZoneListRS'] as $fila){
foreach($fila as $elemento[]){
echo($elemento[$i]['!Name']);
$i++;
echo "<br />";
}
}
Pero si es una chorizo más complicado como este:
array(1) { ["OTA_HotelAvailRS"]=> array(3) { ["Success"]=> string(0) "" ["RoomStays"]=> array(1) { ["RoomStay"]=> array(99) { [0]=> array(6) { ["RoomTypes"]=> string(0) "" ["RoomRates"]=> array(1) { ["RoomRate"]=> array(4) { [0]=> array(5) { ["Rates"]=> array(1) { ["Rate"]=> array(5) { ["Total"]=> array(2) { ["!AmountAfterTax"]=> string(5) "67.94" ["!DecimalPlaces"]=> string(1) "2" } ["RateDescription"]=> array(1) { ["Text"]=> string(8) "Standard" } ["TPA_Extensions"]=> array(1) { ["DailyBreakdown"]=> string(5) "67.94" } ["!NumberOfUnits"]=> string(1) "1" ["!RateMode"]=> string(4) "Room" } } ["Total"]=> array(3) { ["!AmountAfterTax"]=> string(5) "67.94" ["!CurrencyCode"]=> string(3) "USD" ["!DecimalPlaces"]=> string(1) "2" } ["!RatePlanCode"]=> string(152) "/eEaQ/eE0sK1J7XaY2n2fvmbix4vd6oIm/H/JsqI/1WOHHaSpsVubAMBhk4aA+QpHaoB2cyJ5+ei7YACfkhFG8JUOBz 0Cqsff7UR7WNhazKjDvIxRTvZcxlfbUoTQdzZlKse12gAyhLVO pDTplmUHg==" ["!RatePlanCategory"]=> string(9) "Room only" ["!AvailabilityStatus"]=> string(16) "AvailableForSale" } [1]=> array(5) { ["Rates"]=> array(1) { ["Rate"]=> array(5) { ["Total"]=> array(2) { ["!AmountAfterTax"]=> string(5) "67.94" ["!DecimalPlaces"]=> string(1) "2" } ["RateDescription"]=> array(1) { ["Text"]=> string(21) "Standard (Double bed)" } ["TPA_Extensions"]=> array(1) { ["DailyBreakdown"]=> string(5) "67.94" } ["!NumberOfUnits"]=> string(1) "1" ["!RateMode"]=> string(4) "Room" } } ["Total"]=> array(3) { ["!AmountAfterTax"]=> string(5) "67.94" ["!CurrencyCode"]=> string(3) "USD" ["!DecimalPlaces"]=> string(1) "2" }
(no está el chorizo entero)
No hay una forma más fácil para parsear el array??? |