I. mathematical function library ● floor provides an integer (rounded down) floatfloor (float $ value); ● ceil performs an integer (rounded up) floatceil (float $ value ); ● max takes the maximum value of mixedmax (mixed $ value, mixed $ value,); ●
I. mathematical functions Library
● Floor
Rounding (rounding down)
Float floor (float $ value );
");echo(floor(0.40)."
");echo(floor(5)."
");echo(floor(5.1)."
");echo(floor(-5.1)."
");echo(floor(-5.9)."
")?>
● Ceil
One integer (rounded up)
Float ceil (float $ value );
");echo(ceil(0.40)."
");echo(ceil(5)."
");echo(ceil(5.1)."
");echo(ceil(-5.1)."
");echo(ceil(-5.9)."
")?>
● Max
Maximum value
Mixed max (mixed $ value, mixed $ value ,......);
");echo(max(-3,5)."
");echo(max(-3,-5)."
");echo(max(7.25,7.30)."
");?>
● Min
Minimum value
Mixed min (mixed $ value, mixed $ value ,......);
");echo(min(-3,5)."
");echo(min(-3,-5)."
");echo(min(7.25,7.30)."
");?>
● Pow
Power operation
Number pow (number $ base, number $ expr );
";echo pow(6,2)."
";echo pow(-6,2)."
";echo pow(-6,-2)."
";echo pow(-6,5.5)."
";?>
● Sqrt
Take the square root
Float sqrt (float $ arg)
";echo(sqrt(1))."
";echo(sqrt(9))."
";echo(sqrt(0.64))."
";echo(sqrt(-9))."
";?>
● Rand
Generate random number
Int mt_rand (int $ min, int max );
";echo rand(10,100)."
";?>
● Mt_rand
Generate a better random number
Int mt_rand (int $ min, int max );
Similar to the preceding rand usage and output results, this is four times faster than rand.
● Round
Rounding
Float round (float $ val [, int $ precision = 0])
Optional; number of decimal places
●Number_format
Format a number using a thousand-bit grouping
Float number_format (float $ number, int $ decimals = 0, string $ dec_point = ", ', string $ thousands_sep = ',');
II. date and time function library
● Time
Returns the current Unix timestamp.
Int time (void );
";$nextWeek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60secsecho 'Now: '. date('Y-m-d') ."
";echo 'Next Week: '. date('Y-m-d', $nextWeek) ."
";?>
● Date
Format a local time/date
String date (string format [, int timestamp]);
● Getdate
Get date/time information
Array getdate ([int timestamp]);
MD5 hash
String md5 (string $ str [, bool $ raw_output = false]);
Strpos
Returns the position where one character appears for the first time.
Int strpos (string haystack, mixed needle [, int offset]);