我有两个数组,我已经从json对象解码。我需要将它们合并为一个数组。创建一个包含所有键值的单个数组。
第一个数组看起来像 -
Array
(
[HotelListResponse] => Array
(
[customerSessionId] => 0ABAAACE-195B-3203-9142-76C8B9F63986
[numberOfRoomsRequested] => 1
[moreResultsAvailable] => 1
[cacheKey] => 195b3203:1476c8b9f63:8b
[cacheLocation] => 10.186.170.206:7300
[cachedSupplierResponse] => Array
(
[@supplierCacheTolerance] => NOT_SUPPORTED
[@cachedTime] => 0
[@supplierRequestNum] => 216
[@supplierResponseNum] => 20
[@supplierResponseTime] => 404
[@candidatePreptime] => 39
[@otherOverheadTime] => 26
[@tpidUsed] => 5202
[@matchedCurrency] => true
[@matchedLocale] => true
)
[HotelList] => Array
(
[@size] => 20
[@activePropertyCount] => 237
[HotelSummary] => Array
(
[0] => Array
(
[@order] => 0
[@ubsScore] => 4336013
[hotelId] => 214631
[name] => Chateau Windsor Hotel
[address1] => 86, Veer Nariman Road
[address2] => Next to Ambassador Hotel
[city] => Mumbai
[postalCode] => 400020
[countryCode] => IN
[airportCode] => BOM
[supplierType] => E
[propertyCategory] => 1
[hotelRating] => 3
[confidenceRating] => 52
[amenityMask] => 32768
[tripAdvisorRating] => 4
[tripAdvisorReviewCount] => 301
[tripAdvisorRatingUrl] => http://www.tripadvisor.com/img/cdsi/img2/ratings/traveler/4.0-12345-4.gif
[locationDescription] => Near Rajabai Tower
[shortDescription] => <p><b>Property Location</b> <br />With a stay at Chateau Windsor Hotel, you'll be centrally located in Mumbai, steps from Brabourne Stadium and minutes from Eros Theater. This hotel is close to
[highRate] => 5000
[lowRate] => 4250
[rateCurrencyCode] => INR
[latitude] => 18.9334
[longitude] => 72.82512
[proximityDistance] => 5.430785
[proximityUnit] => MI
[hotelInDestination] => 1
[thumbNailUrl] => /hotels/1000000/900000/893600/893528/893528_5_t.jpg
[deepLink] => http://travel.ian.com/index.jsp?pageName=hotAvail&cid=55505&hotelID=214631&mode=2&numberOfRooms=1&room-0-adult-total=2&room-0-child-total=0&arrivalMonth=6&arrivalDay=25&departureMonth=6&departureDay=28&showInfo=true&locale=en_US¤cyCode=INR
[RoomRateDetailsList] => Array
(
[RoomRateDetails] => Array
(
[roomTypeCode] => 200099868
[rateCode] => 200591602
[maxRoomOccupancy] => 4
[quotedRoomOccupancy] => 2
[minGuestAge] => 0
[roomDescription] => Superior Room
[propertyAvailable] => 1
[propertyRestricted] =>
[expediaPropertyId] => 893528
[RateInfos] => Array
(
[@size] => 1
[RateInfo] => Array
(
[@priceBreakdown] => true
[@promo] => true
[@rateChange] => false
[RoomGroup] => Array
(
[Room] => Array
(
[numberOfAdults] => 2
[numberOfChildren] => 0
)
)
[ChargeableRateInfo] => Array
(
[@averageBaseRate] => 5000.0
[@averageRate] => 4250.0
[@commissionableUsdTotal] => 212.13
[@currencyCode] => INR
[@maxNightlyRate] => 4250.0
[@nightlyRateTotal] => 12750.0
[@surchargeTotal] => 2221.05
[@total] => 14971.05
[NightlyRatesPerRoom] => Array
(
[@size] => 3
[NightlyRate] => Array
(
[0] => Array
(
[@baseRate] => 5000.0
[@rate] => 4250.0
[@promo] => true
)
[1] => Array
(
[@baseRate] => 5000.0
[@rate] => 4250.0
[@promo] => true
)
[2] => Array
(
[@baseRate] => 5000.0
[@rate] => 4250.0
[@promo] => true
)
)
)
[Surcharges] => Array
(
[@size] => 1
[Surcharge] => Array
(
[@type] => TaxAndServiceFee
[@amount] => 2221.05
)
)
)
[nonRefundable] => 1
[rateType] => MerchantStandard
[promoId] => 205317948
[promoDescription] => Sale! Save 15% on this Stay.
[promoType] => Standard
[currentAllotment] => 8
)
)
[ValueAdds] => Array
(
[@size] => 1
[ValueAdd] => Array
(
[@id] => 2
[description] => Continental Breakfast
)
)
)
)
)
)
)
)
)
和这个数组
Array
(
[ResponseReferenceKey] => uCa3gAcgZY4eG04o38HGDg==
[HotelSearchResults] => Array
(
[Hotels] => Array
(
[0] => Array
(
[idContext] =>
[LowestRate] => Array
(
[LowestRate] => Array
(
[taxes] =>
[value] => 5700
[CurrencyCode] => INR
)
[DiscountedLowestRate] => Array
(
[taxes] =>
[value] => 5700
[CurrencyCode] => INR
)
)
[chainCode] =>
[nameCode] =>
[IsMysteryHotel] =>
[Name] => The Orchid
[id] => 20070418200017894
[PropertyInfo] => Array
(
[Facets] => Array
(
[0] => Array
(
[FacetValue] => Array
(
[value] => 5
[id] =>
[count] =>
)
[group] => STAR_RATING
)
[1] => Array
(
[FacetValue] => Array
(
[value] =>
[id] =>
[count] =>
)
[group] => CHAIN
)
[2] => Array
(
[FacetValues] => Array
(
[0] => Array
(
[value] => Gym
[id] =>
[count] =>
)
)
[group] => AMENITIES
)
)
[GuestRecommendations] => Array
(
[OverallRecommendation] => Array
(
[recommended] => 1
[DateTime] => 2014-03-03
[Rating] => Array
(
[maxRating] => 5
[value] => 5
)
[Comment] => Beautiful 5-star hotel. Awesome breakfast buffet (The best!!!)
[UserName] => Daniel Block
)
[IndividualGuestRecommendations] => Array
(
[0] => Array
(
[recommended] => 1
[DateTime] => 2014-03-03
[Rating] => Array
(
[maxRating] => 5
[value] => 5
)
[Comment] => Beautiful 5-star hotel. Awesome breakfast buffet (The best!!!)
[UserName] => Daniel Block
)
)
[totalRecommendations] => 61
)
[RoomStays] => Array
(
[0] => Array
(
[RoomTypes] => Array
(
[0] => Array
(
[bedTypeCode] =>
[nonSmoking] =>
[code] => 3
[name] => Deluxe
)
)
[RatePlans] => Array
(
[0] => Array
(
[code] => 94882176967240
[bundledTariff] =>
[MealPlans] => Array
(
[0] => Array
(
[code] => EP
[start] => 2014-08-03
[end] => 2014-08-05
[value] => Room Only
)
)
[Inclusions] => Array
(
[0] => Array
(
[code] => Two Way Airport Transfer
[start] => 2014-08-03
[end] => 2014-08-05
[value] => Two Way Airport Transfer
)
)
[name] => 94882176967240
[type] => OFFLINE
)
)
[RoomRates] => Array
(
[0] => Array
(
[inclusionAndPolicyAvail] => 1
[availableCount] => 25
[availStatus] => B
[Rate] => Array
(
[CancelPenalties] => Array
(
[0] => Array
(
[PenaltyDescription] => Array
(
[name] =>
[value] => More than 2 days before check-in date: FREE CANCELLATION. 2 days before check-in date: 1 night cost will be charged as cancellation fee. In case of no show: no refund. An additional MakeMyTrip service charge of INR 250 will apply
)
[type] =>
)
)
[RoomTariffs] => Array
(
[0] => Array
(
[Tariffs] => Array
(
[0] => Array
(
[amount] => 11400
[amountBeforeTax] =>
[amountAfterTax] =>
[type] => ROOM_RENT
[group] => ROOM_RATE
[currencyCode] => INR
)
)
[ExtraBedsIncluded] =>
[roomNumber] => 1
)
)
[PromotionReferences] => Array
(
)
)
[roomTypeCode] => 3
[ratePlanCode] => 94882176967240
)
)
[availStatus] => B
[startDate] => 2014-08-03
[endDate] => 2014-08-05
)
)
[Promotions] => Array
(
[0] => Array
(
[promotionName] =>
[code] => 39159894181198221
[TNCLink] =>
[promoLevel] => TARIFF_LEVEL_PROMO
[priceSlasher] => 1
[startDate] =>
[endDate] =>
[promoType] => PROMO_TYPE_DEAL
[value] => STAY MORE SAVE MORE !!!
)
)
[MediaList] => Array
(
[0] => Array
(
[main] => 1
[RoomCode] =>
[type] => IMAGE
[src] => http://images1.makemytrip.com/mmtimgs/images/upload/TheOrchid_Facade_Listing.jpg
)
)
)
)
[POS] => Array
(
[Requestor] => Array
(
[idContext] => AFF
[sourceId] =>
[id] => AFF304443
[type] => AFF
[channel] => AFF
)
[Source] => Array
(
[iSOCurrency] => INR
)
)
[AllHotels] => 1
[ResponseCode] => Array
(
[success] => 1
)
)
我在php中这样做。所以请帮帮我。 提前谢谢。
答案 0 :(得分:0)
您正在寻找功能array_merge()
..您可以这样做
<?php
$a1=array(); //add ur elements into the array
$a2=array();
print_r(array_merge($a1,$a2));
答案 1 :(得分:0)
然后你正在寻找这段代码:
$result = array($array1, $array2);
print_r($result);
您将我们与合并混为一谈,因为合并总是意味着从两件或更多件事创建一件事。对于未来,如果您还可以向我们提供结果应该如何的话,那么最好也是最好的...没有必要插入如此大量的数据。