The way to customize the values of an array with the way which you wan’t it to be customized. Just suppose we have an array like this
<?php $abc = array( 10, 12, 9, 8, 30 ); ?>
You wan’t to have a multiplication with a certain number with all these array values. You will use array_map() function so that you can do any thing that you wan’t with your array values. Its quite simple let me write code for you for an example.
Code Example:
<?php function customFunction( $a ) { return( $a * $a ); } $abc = array( 10, 12, 9, 8, 30 ); echo "<pre>"; print_r(array_map("customFunction",$abc)); ?>
Result:
Array ( [0] => 100 [1] => 144 [2] => 81 [3] => 64 [4] => 900 )
You will get this result because in the code above you are multiplying your values by itself. You can customize it by changing the function above. You can do something more big only just like you are receiving the value in the customFunction you can place your whole logic in it to make it beneficial according to your needs.