Here we are changing all negative numbers to positive numbers.
Changing all negative numbers of an array
We can take an array with both negative and positive numbers. We will use array_map() built in PHP function to change all negative elements to positive by using abs function.
<?Php
$a= array(1,-2,4,-7.3,105);
$b=array_map("abs",$a);
while (list ($key, $val) = each ($b)) {
echo "$key -> $val <br>";
}
?>