3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = [ ['order' => null, 'seriesId' => 1], ['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'); } } validateOrderUniqueness($data); validateSeriesUniqueness($data);
based on Zuen0
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Exception: validateSeriesUniqueness fail in /in/YdL3n:24 Stack trace: #0 /in/YdL3n(29): validateSeriesUniqueness(Array) #1 {main} thrown in /in/YdL3n on line 24
Process exited with code 255.
Output for 5.5.24 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'validateSeriesUniqueness fail' in /in/YdL3n:24 Stack trace: #0 /in/YdL3n(29): validateSeriesUniqueness(Array) #1 {main} thrown in /in/YdL3n on line 24
Process exited with code 255.
Output for 5.4.12 - 5.4.45
Fatal error: Call to undefined function array_column() in /in/YdL3n on line 10
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/YdL3n on line 3
Process exited with code 255.