<html>
<body>
$strings = ["apple", "orange", "banana", "coconut"];
$lengths = array_map( function($item) { return strlen($item); } , $strings);
print_r($lengths);
</body>
<!-- Mirrored from www.w3schools.com/php/phptryit.asp?filename=tryphp_callback_functions2 by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 21 Dec 2022 17:22:24 GMT -->
</html>
Array ( [0] => 5 [1] => 6 [2] => 6 [3] => 7 )