Skip to content

Instantly share code, notes, and snippets.

@d30jeff
Created February 17, 2016 03:14
Show Gist options
  • Save d30jeff/c136480bf9852c5680a1 to your computer and use it in GitHub Desktop.
Save d30jeff/c136480bf9852c5680a1 to your computer and use it in GitHub Desktop.
Ok tak soalan nie sebagai internship interview question? In a string containing many words, find the longest word.
<?php
$arr = ['a', 'bc', 'def', 'longest'];
usort($arr, function($a, $b) {
return strlen($b) - strlen($a);
});
echo $arr[0];
@coolcodemy
Copy link

@coolcodemy
Copy link

alamak tak boleh la pulak guna max... -_-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment