3v4l.org

run code in 300+ PHP versions simultaneously
<?php $subject = array( array("Yolo" => "Swag", 2, 3), array("Thwag" => "Molo", 2, 4), array("Yolo" => "Thwag", 2, 3) ); $unique = array_reduce($subject, function($final, $article){ static $seen = array(); if ( ! array_key_exists($article[2], $seen)) { $seen[$article[2]] = NULL; $final[] = $article; } return $final; }); print_r($subject); print_r($unique);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key 2 in /in/78qjW on line 10 Warning: Undefined array key 2 in /in/78qjW on line 11 Warning: Undefined array key 2 in /in/78qjW on line 10 Warning: Undefined array key 2 in /in/78qjW on line 10 Array ( [0] => Array ( [Yolo] => Swag [0] => 2 [1] => 3 ) [1] => Array ( [Thwag] => Molo [0] => 2 [1] => 4 ) [2] => Array ( [Yolo] => Thwag [0] => 2 [1] => 3 ) ) Array ( [0] => Array ( [Yolo] => Swag [0] => 2 [1] => 3 ) )

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:
37.77 ms | 403 KiB | 8 Q