cheechm Posted September 19, 2008 Share Posted September 19, 2008 Hi, How would I get each unique value for "Carrier"? Array ( [shipAction] => ServiceInfo [status] => Success [RequestDate] => 2008-09-20 00:21:13 [username] => Nick [serviceInfo] => Array ( [DHL10_UKUK] => Array ( [serviceID] => DHL10_UKUK [Carrier] => DHL Home [DeliveryName] => Next Day Delivery by 10am [serviceLength] => Delivery made next day by 10am throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 7am and 9pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => Free redelivery can be arranged direct with the carrier [PrinterRequired] => No ) [DHL48_UKUK] => Array ( [serviceID] => DHL48_UKUK [Carrier] => DHL Home [DeliveryName] => Home 48 (UK to UK) [serviceLength] => 1-2 working day delivery throughout most of the UK. 90% of deliveries are made next day. [serviceHours] => 48 [DeliveryTimes] => Deliveries take place between 7am and 9pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => Free redelivery can be arranged direct with the carrier [PrinterRequired] => No ) [DHLSAT_UKUK] => Array ( [serviceID] => DHLSAT_UKUK [Carrier] => Saturday AM [DeliveryName] => Delivery on Saturday before 12.00 noon [serviceLength] => Delivery made on Saturday before 12.00 noon [serviceHours] => 24 [DeliveryTimes] => Deliveries made before 12.00 noon [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => Free redelivery can be arranged direct with the carrier [PrinterRequired] => No ) [DHL_EROP] => Array ( [serviceID] => DHL_EROP [Carrier] => DHL [DeliveryName] => DHL Euro Plus [serviceLength] => Delivery time 2 - 3 working days [serviceHours] => 72 [DeliveryTimes] => Deliveries take place between 7am and 9pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [DHL_TD] => Array ( [serviceID] => DHL_TD [Carrier] => DHL TD [DeliveryName] => Time Definite [serviceLength] => Delivery time 1 - 2 working days [serviceHours] => 48 [DeliveryTimes] => Deliveries take place between 7am and 9pm [Paperwork] => You must print a barcode waybill onto A4 paper after you have submitted your order [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => Yes ) [DPD_10UKUK] => Array ( [serviceID] => DPD_10UKUK [Carrier] => DPD [DeliveryName] => DPD 10.00 UK to UK) [serviceLength] => Delivery made next day by 10am throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [DPD_12UKUK] => Array ( [serviceID] => DPD_12UKUK [Carrier] => DPD [DeliveryName] => DPD 12.00 (UK to UK) [serviceLength] => Delivery made next day by 12.00 noon throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [DPD_CLSC] => Array ( [serviceID] => DPD_CLSC [Carrier] => DPD [DeliveryName] => DPD CLASSIC [serviceLength] => Delivery time 2 - 5 working days [serviceHours] => 120 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [DPD_EXP] => Array ( [serviceID] => DPD_EXP [Carrier] => DPD [DeliveryName] => DPD EXPRESS [serviceLength] => Delivery time 3 - 4 working days [serviceHours] => 96 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [DPD_NDUKUK] => Array ( [serviceID] => DPD_NDUKUK [Carrier] => DPD [DeliveryName] => DPD Next Day (UK to UK) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [P4D_24NI] => Array ( [serviceID] => P4D_24NI [Carrier] => TNT [DeliveryName] => P4D Trident 24 (NI) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => An ideal service for sending heavier and bulkier items. Not suitable for pallets [PrinterRequired] => No ) [P4D_24SH] => Array ( [serviceID] => P4D_24SH [Carrier] => TNT [DeliveryName] => P4D Trident 24 (SH) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => An ideal service for sending heavier and bulkier items. Not suitable for pallets [PrinterRequired] => No ) [P4D_TR24] => Array ( [serviceID] => P4D_TR24 [Carrier] => TNT [DeliveryName] => P4D Trident 24 [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => An ideal service for sending heavier and bulkier items. Not suitable for pallets [PrinterRequired] => No ) [P4D_TRNOON] => Array ( [serviceID] => P4D_TRNOON [Carrier] => TNT [DeliveryName] => P4D Trident by noon [serviceLength] => Delivered by noon, next working day [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => An ideal service for sending heavier and bulkier items. Not suitable for pallets [PrinterRequired] => No ) [PF24_IMIM] => Array ( [serviceID] => PF24_IMIM [Carrier] => PF [DeliveryName] => 24 Hour delivery (IOM to IOM) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_IMIW] => Array ( [serviceID] => PF24_IMIW [Carrier] => PF [DeliveryName] => 24 Hour delivery (IOM to IOW) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_IMNI] => Array ( [serviceID] => PF24_IMNI [Carrier] => PF [DeliveryName] => 91rthern Ireland (IOM to NI) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_IMUK] => Array ( [serviceID] => PF24_IMUK [Carrier] => PF [DeliveryName] => 24 Hour delivery (IOM to UK) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_IWIM] => Array ( [serviceID] => PF24_IWIM [Carrier] => PF [DeliveryName] => 24 Hour delivery (IOW to IOM) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_IWIW] => Array ( [serviceID] => PF24_IWIW [Carrier] => PF [DeliveryName] => 24 Hour delivery (IOW to IOW) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_IWNI] => Array ( [serviceID] => PF24_IWNI [Carrier] => PF [DeliveryName] => Northern Ireland (IOW to NI) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_IWUK] => Array ( [serviceID] => PF24_IWUK [Carrier] => PF [DeliveryName] => 24 Hour delivery (IOW to UK) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_NIIM] => Array ( [serviceID] => PF24_NIIM [Carrier] => PF [DeliveryName] => 24 Hour delivery (NI to IOM) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_NIIW] => Array ( [serviceID] => PF24_NIIW [Carrier] => PF [DeliveryName] => 24 Hour delivery (NI to IOW) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_NINI] => Array ( [serviceID] => PF24_NINI [Carrier] => PF [DeliveryName] => Northern Ireland (NI to NI) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_NIUK] => Array ( [serviceID] => PF24_NIUK [Carrier] => PF [DeliveryName] => 24 Hour delivery (NI to UK) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) [PF24_SHIM] => Array ( [serviceID] => PF24_SHIM [Carrier] => PF [DeliveryName] => 24 Hour delivery (SH to IOM) [serviceLength] => Next working day delivery throughout most of the UK guaranteed [serviceHours] => 24 [DeliveryTimes] => Deliveries take place between 9.00 am and 5.30 pm [Paperwork] => The collection van driver will bring the relevant paprwork (waybill) [CollectionTimes] => Sameday collection Deadline 12.00pm. Or book in advance [insurance] => 50 GBP worth of insurance included free with every order. Additional cover available. [insuranceIncluded] => 50 [Notes] => [PrinterRequired] => No ) ) ) I have foreach ($response['ServiceInfo'] as $key => $value) { echo $response['ServiceInfo'][$key]['Carrier'] ."\n"; } and I want each unique value for $response['ServiceInfo'][$key]['Carrier'] Thanks Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/ Share on other sites More sharing options...
JasonLewis Posted September 20, 2008 Share Posted September 20, 2008 foreach($response['ServiceInfo'] as $key => $val){ echo $val['Carrier']."<br />"; } I think.. Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/#findComment-646066 Share on other sites More sharing options...
Zane Posted September 20, 2008 Share Posted September 20, 2008 Actually you go about it like this $carriers = array(); foreach($response['ServiceInfo'] as $key => $val){ if($key == "Carrier") { $carriers[] = $val; } } Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/#findComment-646111 Share on other sites More sharing options...
Psycho Posted September 20, 2008 Share Posted September 20, 2008 He said "unique" values: $carriers = array(); foreach($response['ServiceInfo'] as $shipment) { if($shipment['Carrier'] && !in_array($shipment['Carrier'], $carriers)) { $carriers[] = $shipment['Carrier']; } } Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/#findComment-646117 Share on other sites More sharing options...
F1Fan Posted September 20, 2008 Share Posted September 20, 2008 You could even use the carrier as the key, then just overwrite it every time. Then, use the keys as the values: $carriers = array(); foreach($response['ServiceInfo'] as $shipment) { $carriers[$shipment['Carrier']] = $shipment['Carrier']; } Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/#findComment-646200 Share on other sites More sharing options...
Zane Posted September 20, 2008 Share Posted September 20, 2008 now there's a nifty idea...I don't know why I have never thought of that that's so simple Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/#findComment-646202 Share on other sites More sharing options...
F1Fan Posted September 20, 2008 Share Posted September 20, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/#findComment-646205 Share on other sites More sharing options...
Psycho Posted September 20, 2008 Share Posted September 20, 2008 Or you could simply create an array of all the values - duplicates and all - then use array_unique() $carriers = array(); foreach($response['ServiceInfo'] as $shipment) { $carriers[] = $shipment['Carrier']; } array_unique($carriers); Quote Link to comment https://forums.phpfreaks.com/topic/125020-solved-arrays/#findComment-646468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.