3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( 'Google', 'Facebook', "Test1112", 'Twitter', 'Slack', 'Twilio' ); usort($array, function ($a, $b) { return strlen($a) < strlen($b); }); $item = reset($array); $result = []; if ($item) { $len = strlen($item); foreach($array as $value) { if (strlen($value) === $len) { $result[] = $value; continue; } break; } } print_r($result);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: usort(): Returning bool from comparison function is deprecated, return an integer less than, equal to, or greater than zero in /in/q5d8X on line 12 Array ( [0] => Facebook [1] => Test1112 )

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:
138.39 ms | 406 KiB | 5 Q