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); if (count(array_diff($existing, $seriesIds)) > 0) { $this->error(self::MISSING_ORDER_OF_SERIES); } if (count(array_diff($seriesIds, $existing)) > 0) { $this->error(self::NON_EXISTING_SERIES); }
based on 57cg0
Output for 7.2.0
Notice: Undefined variable: seriesIds in /in/cYSUR on line 33 Warning: array_diff(): Argument #2 is not an array in /in/cYSUR on line 33 Warning: count(): Parameter must be an array or an object that implements Countable in /in/cYSUR on line 33 Notice: Undefined variable: seriesIds in /in/cYSUR on line 37 Warning: array_diff(): Argument #1 is not an array in /in/cYSUR on line 37 Warning: count(): Parameter must be an array or an object that implements Countable in /in/cYSUR on line 37
Output for 5.5.24 - 7.1.10
Notice: Undefined variable: seriesIds in /in/cYSUR on line 33 Warning: array_diff(): Argument #2 is not an array in /in/cYSUR on line 33 Notice: Undefined variable: seriesIds in /in/cYSUR on line 37 Warning: array_diff(): Argument #1 is not an array in /in/cYSUR on line 37
Output for 5.4.12 - 5.4.45
Fatal error: Call to undefined function array_column() in /in/cYSUR on line 10
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/cYSUR on line 3
Process exited with code 255.