3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = [ // ['order' => null, 'seriesId' => 2], // ['order' => 0, 'seriesId' => 1], ]; function validateOrderUniqueness(array $data) { $orders = array_filter(array_column($data, 'order')); $uniqueOrders = array_unique($orders); if ($orders !== $uniqueOrders) { throw new \Exception('validateOrderUniqueness fail'); } } function validateSeriesUniqueness(array $data) { $seriesIds = array_column($data, 'seriesId'); $uniqueSeriesIds = array_unique($seriesIds); if ($seriesIds !== $uniqueSeriesIds) { throw new \Exception('validateSeriesUniqueness fail'); } } $existing = [1, 2, 3]; validateOrderUniqueness($data); validateSeriesUniqueness($data); $seriesIds = array_column($data, 'seriesId'); if (count(array_diff($existing, $seriesIds)) > 0) { throw new \Exception('MISSING_ORDER_OF_SERIES fail'); } if (count(array_diff($seriesIds, $existing)) > 0) { throw new \Exception('NON_EXISTING_SERIES fail'); }
based on uGRV5
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Exception: MISSING_ORDER_OF_SERIES fail in /in/gACFB:36 Stack trace: #0 {main} thrown in /in/gACFB on line 36
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'MISSING_ORDER_OF_SERIES fail' in /in/gACFB:36 Stack trace: #0 {main} thrown in /in/gACFB on line 36
Process exited with code 255.
Output for 5.4.12 - 5.4.45
Fatal error: Call to undefined function array_column() in /in/gACFB on line 10
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/gACFB on line 3
Process exited with code 255.