3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subscription = json_decode('{ "Subscription": { "Id": 18849027, "Subscriptionstatus": 1, "NextBillingDate": "2018-07-08T15:31:08.654877", "NextBillingDateReminder": "2018-07-01T15:31:08.654877Z", "GracePeriodDays": 0, "StartIntervalDayCount": 0, "StartIntervalMonthCount": 1, "IntervalDayCount": 0, "IntervalMonthCount": 1, "CustomerId": 73771655, "CustomerReferenceId": "6kQ5CSMofkLdC0GQCn0EMgPzfAJ4ctN3F2JsAWQJ", "CustomerCurrencyId": "EUR", "CustomerReferenceNo": "", "LastIntervalNo": 22, "StartDate": "2016-08-08T15:31:08.654877", "EndDate": null, "Items": [ { "SubscriptionId": 18849027, "RunningNo": 1, "Quantity": 1, "ProductId": 82973, "ProductName": "FastBill Complete", "ProductNameExtension": "Monats-Abonnement", "RecurrenceCount": null, "Status": 1, "DeactivationDate": null, "StartDate": "2016-08-08T15:31:08.654877", "EndDate": null, "LastIntervalNo": 22, "IsCurrent": true, "Version": 1, "Couponcode": "", "PromotionId": null, "SubscriptionPurchaseItems": [ { "PurchaseId": 95742459, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 0 }, { "PurchaseId": 97512712, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 1 }, { "PurchaseId": 103064464, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 4 }, { "PurchaseId": 108481281, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 7 }, { "PurchaseId": 112016777, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 9 }, { "PurchaseId": 113701986, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 10 }, { "PurchaseId": 115302274, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 11 }, { "PurchaseId": 117286219, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 12 }, { "PurchaseId": 119449074, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 13 }, { "PurchaseId": 123308459, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 15 }, { "PurchaseId": 125233367, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 16 }, { "PurchaseId": 127322800, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 17 }, { "PurchaseId": 131151673, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 19 }, { "PurchaseId": 132734325, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 20 }, { "PurchaseId": 135749578, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 21 }, { "PurchaseId": 138141409, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 22 }, { "PurchaseId": 129265950, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 18 }, { "PurchaseId": 99299879, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 2 }, { "PurchaseId": 101140707, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 3 }, { "PurchaseId": 104979919, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 5 }, { "PurchaseId": 106823347, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 6 }, { "PurchaseId": 110335886, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 8 }, { "PurchaseId": 121485688, "PurchaseItemRunningNo": 1, "SubscriptionIntervalNo": 14 } ] } ] }, "ResultMessage": "OK" }'); function cmp($a, $b) { if ($a['SubscriptionIntervalNo'] == $b['SubscriptionIntervalNo']) { return 0; } return ($a['SubscriptionIntervalNo'] < $b['SubscriptionIntervalNo']) ? -1 : 1; } print_r($subscription->Subscription->Items[0]->SubscriptionPurchaseItems); print_r(usort($subscription->Subscription->Items[0]->SubscriptionPurchaseItems,"cmp")); print_r($subscription);

preferences:
59.24 ms | 402 KiB | 5 Q