3v4l.org

run code in 300+ PHP versions simultaneously
<?php $method_filters = [ 'exists' => [ 'full pallet' => [ 171 => [ 'pakkelabels_shipping_gls_private', 'pakkelabels_shipping_postnord_private', 'pakkelabels_shipping_gls', 'pakkelabels_shipping_pdk', 'flat_rate:15', 'flat_rate:14' ], ], 'half pallet' => [ 169 => [ 'pakkelabels_shipping_gls_private', 'pakkelabels_shipping_postnord_private', 'pakkelabels_shipping_gls', 'pakkelabels_shipping_pdk', 'flat_rate:15' ], ], 'quarter pallet' => [ 211 => [ 'pakkelabels_shipping_gls_private', 'pakkelabels_shipping_postnord_private', 'pakkelabels_shipping_gls', 'pakkelabels_shipping_pdk' ], ] ], 'not exists' => [ 'full pallet' => [ 171 => [ 'flat_rate:12' ] ], 'half pallet' => [ 169 => [ 'flat_rate:14' ] ], 'quarter pallet' => [ 211 => [ 'flat_rate:15' ] ] ] ]; $class_ids[170] = ''; $class_ids[171] = ''; $available_shipping_methods['flat_rate:12'] = 'something'; $available_shipping_methods['flat_rate:14'] = 'somethingelse'; foreach ($method_filters as $filter_type => $pallet_filters) { // iterate exists/not exists level foreach ($pallet_filters as $pallet_type => $shipping_methods) { // iterate different pallets level if ($filter_type == 'exists') { $qualifiers = array_intersect_key($shipping_methods, $class_ids); } else { $qualifiers = array_diff_key($shipping_methods, $class_ids); } foreach ($qualifiers as $class_id => $method_names) { // only iterate if there are qualifying class ids foreach ($method_names as $method_name) { echo "unsetting $method_name\n"; unset($available_shipping_methods[$method_name]); } } } } var_export($available_shipping_methods);
Output for git.master, git.master_jit, rfc.property-hooks
unsetting pakkelabels_shipping_gls_private unsetting pakkelabels_shipping_postnord_private unsetting pakkelabels_shipping_gls unsetting pakkelabels_shipping_pdk unsetting flat_rate:15 unsetting flat_rate:14 unsetting flat_rate:14 unsetting flat_rate:15 array ( 'flat_rate:12' => 'something', )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
54.4 ms | 401 KiB | 8 Q