3v4l.org

run code in 300+ PHP versions simultaneously
<?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); }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined variable $seriesIds in /in/cYSUR on line 33 Fatal error: Uncaught TypeError: array_diff(): Argument #2 must be of type array, null given in /in/cYSUR:33 Stack trace: #0 /in/cYSUR(33): array_diff(Array, NULL) #1 {main} thrown in /in/cYSUR on line 33
Process exited with code 255.

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:
43.47 ms | 401 KiB | 8 Q