Eg:
GetLogestString("bae","afaaa","aaa")
should return 5
GetLogestString("baeedfefe","afaaaa","aaa","bb")
should return 9
Use array_map()
, strlen()
, max()
and func_get_args()
:
function getLongestString() {
$args = func_get_args();
return max(array_map('strlen', $args));
}
Edit: In PHP 5.2 you have to store the result of func_get_args()
in a temporary variable. In PHP 5.3 you can do this:
function getLongestString() {
return max(array_map('strlen', func_get_args()));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With