Apply a function to all the element of an array – PHP

<?php
 $testArray = array(2.4, 2.6, 3.5);
 print_r(array_map('ceil', $testArray));
 // Array ( [0] => 3 [1] => 3 [2] => 4 )

 $testArray = array(2.4, 2.6, 3.5);
 print_r(array_map('floor', $testArray));
 // Array ( [0] => 2 [1] => 2 [2] => 3 )
?>
Share

Leave a Reply

Your email address will not be published. Required fields are marked *