3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ [ "id" => '6230061c0e88d709ca0d7bbc', 'name' => 'Mobile SamSung', 'slug' => 'mobile-samsung', 'createdAt' => '1648006346' ], [ "id" => '5d1eff529a426778d4b92383', 'name' => 'Mobile Iphone', 'slug' => 'mobile-iphone', 'createdAt' => '1647314181' ], [ "id" => '5d1eff6b9a426778d4b92dc4', 'name' => 'Mobile SamSung', 'slug' => 'mobile-samsung', 'createdAt' => '1647314460' ], [ "id" => '5f894011266aea580b028cb0', 'name' => 'Mobile LG', 'slug' => 'mobile-lg', 'createdAt' => '1647314456' ] ]; $newArray = []; foreach ($array as $key => $value) { $findIndex = array_search($value['slug'], array_column($newArray, 'slug')); if ($findIndex === false) { $newArray[] = $value; } elseif ($findIndex !== false && $newArray[$findIndex]['createdAt'] <= $value['createdAt']) { $newArray[$findIndex] = $value; } } print_r($newArray);
Output for rfc.property-hooks, git.master, git.master_jit
Array ( [0] => Array ( [id] => 6230061c0e88d709ca0d7bbc [name] => Mobile SamSung [slug] => mobile-samsung [createdAt] => 1648006346 ) [1] => Array ( [id] => 5d1eff529a426778d4b92383 [name] => Mobile Iphone [slug] => mobile-iphone [createdAt] => 1647314181 ) [2] => Array ( [id] => 5f894011266aea580b028cb0 [name] => Mobile LG [slug] => mobile-lg [createdAt] => 1647314456 ) )

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:
51.2 ms | 1355 KiB | 4 Q