Methods summary
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
#
toMoney( $val, $symbol = '$', $r = 2 )
|
public static
integer
|
#
getPercentageBofA( $valueB, $valueA_orTotalValue, integer $percentageIs = 100 )
Parameters
- $valueB
- $valueA_orTotalValue
- $percentageIs
Returns
integer (return only percentage B of As. e.g percetage 5 of 40 = 12.5%)
|
public static
integer
|
#
getPercentageValue( $value, integer $percentage = 10, integer $noNegativeNumber = true, boolean $percentageIs = 100 )
Parameters
- $value
- $percentage
- $noNegativeNumber
- $percentageIs
- $percentageIs
- $noNegativeNumber
Returns
integer (return only percentage of the value passed in)
|
public static
array
|
#
getValueMinMaxByPercentage( $value, integer $percentage = 10, boolean $noNegativeNumber = true )
Parameters
- $value
- $percentage
- $noNegativeNumber
Returns
array ( array that consist of min, max, percentage or discount, maxFake, and value keys)
|
public static
float
|
#
getAveragePercentage( array $percentageList )
Parameters
- $percentageList
- $percentageList
Returns
float (use when you av more than one percentage to deal with);
e.g (find average percentage of 60%,40%. just convert the two number to
decimal by dividing them with 100, so u get 0.6 & 0.4, then add the two
numbers then divide the result by 2 i.e 0.5, finally multiply he result with 100)
|
public static
|
|
public static
boolean
|
#
isInRange( $value, $min, $max )
Parameters
- $value
- must exists between $min and $max)
- $min
- $max
Returns
boolean
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
string
|
#
toWord( $number, boolean $strictlyNumber = true )
Parameters
Returns
string If you want to convert an integer into an English word string, eg. 29 -> twenty-nine, then here's a function to do it
Note on use of fmod()
I used the floating point fmod() in preference to the % operator, because % converts the operands to int, corrupting values outside of the range [-2147483648, 2147483647]
I haven't bothered with "billion" because the word means 10e9 or 10e12 depending who you ask.
The function returns '#' if the argument does not represent a whole number.
|
public static
boolean
|
#
isEven( $number )
Is integer even number
Parameters
Returns
boolean
|
public static
boolean
|
#
isPrime( $number )
Checks if the provided integer is a prime number.
isPrime(3); // true
Checks if the provided integer is a prime number.
isPrime(3); // true
Parameters
Returns
boolean
|
public static
boolean
|
#
isApproximatelyEqual( $number1, $number2, float $epsilon = 0.001 )
Checks if two numbers are approximately equal to each other.
Use abs() to compare the absolute difference of the two values to epsilon. Omit the third parameter, epsilon, to use a default value of 0.001.
approximatelyEqual(10.0, 10.00001); // true
approximatelyEqual(10.0, 10.01); // false
Checks if two numbers are approximately equal to each other.
Use abs() to compare the absolute difference of the two values to epsilon. Omit the third parameter, epsilon, to use a default value of 0.001.
approximatelyEqual(10.0, 10.00001); // true
approximatelyEqual(10.0, 10.01); // false
Parameters
- $number1
- $number2
- $epsilon
Returns
boolean
|
public static
integer
|
#
getMinNumber( array $numbers )
Returns the n minimum elements from the provided array.
Returns the n minimum elements from the provided array.
Parameters
Returns
integer
|
public static
integer
|
#
getMaxNumber( array $numbers )
Returns the n maximum elements from the provided array.
Returns the n maximum elements from the provided array.
Parameters
Returns
integer
|
public static
float|integer|mixed
|
#
getMedian( array $numbers )
Returns the median of an array of numbers.
median([1, 3, 3, 6, 7, 8, 9]); // 6
median([1, 2, 3, 6, 7, 9]); // 4.5
Returns the median of an array of numbers. median([1, 3, 3, 6, 7, 8, 9]); // 6
median([1, 2, 3, 6, 7, 9]); // 4.5
Parameters
Returns
float|integer|mixed
|
public static
float|integer|mixed
|
#
getLCM( mixed $numbers )
Returns the least common multiple of two or more numbers.
lcm(12, 7); // 84
lcm(1, 3, 4, 5); // 60
Returns the least common multiple of two or more numbers.
lcm(12, 7); // 84
lcm(1, 3, 4, 5); // 60
Parameters
Returns
float|integer|mixed
|
public static
float|integer|mixed
|
#
getGCD( mixed $numbers )
Calculates the greatest common divisor between two or more numbers.
gcd(8, 36); // 4
gcd(12, 8, 32); // 4
Calculates the greatest common divisor between two or more numbers. gcd(8, 36); // 4
gcd(12, 8, 32); // 4
Parameters
Returns
float|integer|mixed
|
public static
array
|
#
fibonacci( $n )
Generates an array, containing the Fibonacci sequence, up until the nth term.
fibonacci(6); // [0, 1, 1, 2, 3, 5]
Generates an array, containing the Fibonacci sequence, up until the nth term.
fibonacci(6); // [0, 1, 1, 2, 3, 5]
Parameters
Returns
array
|
public static
float|integer
|
#
factorial( $n )
Calculates the factorial of a number.
factorial(6); // 720
Calculates the factorial of a number.
factorial(6); // 720
Parameters
Returns
float|integer
|
public static
float|integer
|
#
average( mixed $items )
Returns the average of two or more numbers.
average(1, 2, 3); // 2
Returns the average of two or more numbers.
average(1, 2, 3); // 2
Parameters
Returns
float|integer
|
public static
boolean|string
|
|