Math Functions
<?php 

  // Math functions

    # Function min() finds the lowest value from its arguments, example:
      echo min(21, 78, 20, 47, 89). "\n"; //outputs - 20;
    
    # Function max() finds the highest value from its arguments, example:
      echo max(78, 97, 109, 47, 445). "\n"; //outputs - 445;

    # Function count() counts all elements in the array, example: 
      echo count(67, 89, 76, 54, 9, 90). "\n"; //outputs - 6;

    # Function round() rounds a floating-point number to its nearest integer, example:
      echo(round(9.43)). "\n"; //outputs - 9;
      echo(round(5.5)). "\n"; //outputs - 6;

    # Function floor() rounds the floating-point number down, example:
      echo floor(9.7). "\n"; //outputs - 9;
      echo floor(6.1). "\n"; //outputs - 6;

    # Function ceil() rounds the floating-point number up, example: 
      echo ceil(9.8). "\n"; //outputs - 10;
      echo ceil(7.2). "\n"; //outputs - 8;

    # Function rand() generates a random number, example:
      echo rand(9, 88). "\n"; //outputs some number from 9 to 88;
    
    # Function sqrt() returns the square root of a number, example:
      echo sqrt(81). "\n"; //outputs - 9;

    # Function pow() raises 2 to the power of 3, example:
      echo pow(2, 3). "\n"; //output 8; 

    # Function pi() Returns PI value, example:
      echo pi(). "\n"; //outputs - 3.1415926535898

    # Function abs() returns the positive (absolute) value of a number, example:
      echo abs(-87). "\n"; //outputs - 87;

    # Function decbin() converts decimal number into binary, example: 
      echo decbin(44). "\n"; //outputs - 101100;

?>
by Mariam Gelkhauri
2 years ago
PHP
Math Functions
Object Oriented PHP Tutorial
1
Pro tip: use ```triple backticks around text``` to write in code fences