Found 1046 Articles for PHP

How does the array_diff_key() work in PHP?

AmitDiwan
Updated on 01-Jul-2020 08:39:46

91 Views

It is an inbuilt function that compares the keys of one or more arrays, and returns their difference.Syntax of the array_diff_key functionarray array_diff_key($array1, $array2, ..)The function can take two or more array names as parameters, and compares the first array with the remaining arrays.Example Live DemoOutputArray (    [91] => Micheal )Inside the tags, three arrays are declared with certain values in them. They are printed by calling the ‘array_diff_assoc’ function by passing all the three arrays to it as parameters. The resultant value is the different between the first array, and second array as well as the difference ... Read More

PHP Predefined Mathematical Constants

Malhar Lathkar
Updated on 30-Jun-2020 07:36:18

109 Views

Definition and UsageConstantValueDescriptionM_PI3.14159265358979323846PiM_E2.7182818284590452354Euler Number eM_LOG2E1.4426950408889634074log2 eM_LOG10E0.43429448190325182765log10 eM_LN20.69314718055994530942loge 2M_LN102.30258509299404568402loge10M_PI_21.57079632679489661923pi/2M_PI_40.78539816339744830962pi/4M_1_PI0.318309886183790671541/piM_2_PI0.636619772367581343082/piM_SQRTPI1.77245385090551602729sqrt(pi)M_2_SQRTPI1.128379167095512573902/sqrt(pi)M_SQRT21.41421356237309504880sqrt(2)M_SQRT31.73205080756887729352sqrt(3)M_SQRT1_20.707106781186547524401/sqrt(2)M_LNPI1.14472988584940017414loge(pi)M_EULER0.57721566490153286061Euler constantPHP_ROUND_HALF_UP1Round halves upPHP_ROUND_HALF_DOWN2Round halves downPHP_ROUND_HALF_EVEN3Round halves to even numbersPHP_ROUND_HALF_ODD4Round halves to odd numbersNANNANNot A NumberINFINFInfinity

PHP tanh() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:34:05

81 Views

Definition and UsageThe tanh() function returns the hyperbolic tangent ratio of given angle in radians. In trigonometry, hyperbolic tangent ratio is defined as.tanh(x) = sinh()/tanh()This function returns a float value .Syntaxtanh ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP tanh() function returns hyperbolic tangent ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates tanh(pi/2) and returns 2.5091784786581 which is also the result of formula (ex + e-x))/2 −OutputThis will produce following result −tanh(pi) = 0.91715233566727 using formula = 0.91715233566727Example Live DemoFollowing example uses deg2rad() ... Read More

PHP tan() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:31:07

100 Views

Definition and UsageThe tan() function returns the tangent ratio of given angle in radians. In trigonometry, tangent of an angle is defined as ratio of lengths of opposite side and adjacent side.tan(x) = opposite/adjacenttangent of an angle is also defined as ratio of its sine and cosinetan(x) = sin(x)/cos(x)If x=45 degree, tan(x) = 1 as in a right angled traingle, opposite and adjacent sides are qual.This function returns a float value.Syntaxtan ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP tan() function returns tangent ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP ... Read More

PHP srand() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:29:27

272 Views

Definition and UsageThe srand() function is used to seed the random number generaror. Seeding initializes the random number generator. Most random number generators need initial seeding. In PHP, use of srand() function is optional as it is done automatically.This function doen't have any return value.Syntaxsrand ([ int $seed ] ) : voidParametersSr.NoParameter & Description1seedan integer to be used as seed. If not given, a random number is givenReturn ValuesThis function doesn't return any value.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoThis example the random number generator is first initialized before employing ... Read More

PHP sqrt() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:27:34

2K+ Views

Definition and UsageThe sqrt() function returns square root of a positive float number. Since square root for negative number is not defined, it returns NAN. This is one of the most commonly used functions.This function always returns a floating point number.Syntaxsqrt ( float $arg ) : floatParametersSr.NoParameter & Description1arga number whose square root is to be obtainedReturn ValuesPHP sqrt() function returns square root of the given arg number. For negative number, the function returns NAN.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculate square root of 100−OutputThis will produce following ... Read More

PHP sinh() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:25:47

64 Views

Definition and UsageThe sinh() function calculates hyperbolic sine of given angle in radians. A hyperbolic sine function is defined assinh(x) = (ex – e-x))/2This function returns a float value between Π and -Π.Syntaxsinh( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP sinh() function returns hyperbolic sine ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates sinh(pi/2) and returns 2.3012989023073 which is also the result of formula (ex – e-x))/2−OutputThis will produce following result −sinh(M_PI_2) = 2.3012989023073 using formula = ... Read More

PHP sin() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:23:38

171 Views

Definition and UsageThe sin() function returns the sine ratio of given angle in radians. In trigonometry, sine of an angle is defined as ratio of lengths of opposite side and hypotenuse.sin(x) = opposite/hypotenuseIf x=90 degree, sin(x) = 1 as opposite side of right angle is a hypotenuseThis function returns a float value.Syntaxsin ( float $arg ) : floatParametersSr.NoParameter & Description1argA floating point value that represents angle in radiansReturn ValuesPHP sin() function returns sine ratio of given parameter.PHP VersionThis function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.Example Live DemoFollowing example calculates sin(pi/2) and returns 1. Sine ratio of 90 deg is ... Read More

PHP round() Function

Malhar Lathkar
Updated on 30-Jun-2020 07:21:30

776 Views

Definition and UsageThe round() function proves useful in rounding any floating point number upto a desired precision level. Positive precision parameter causes the number to be rounded after decimal point, whereas with negative precision, rounding occurs before decimal point. Precision is 0 by default.For example, round(10.6) returns 11, round(10.2) returns 10. The function always returns a floating point number.This function also has another optional parameter called mode takes one of the redefined constants described later.Syntaxround ( float $value , int $precision , int $mode ) : floatParametersSr.NoParameter & Description1valueA float number to be rounded2precisionnumber of decimal digits to round to. ... Read More

PHP rand() Function

Malhar Lathkar
Updated on 30-Jun-2020 08:29:10

228 Views

Definition and UsageThe rand() function returns an integer using pseudo random genaration technique. default range is between 0 and platform specific getrandmax(). On 64 bit Windows OS, it is 2147483647. The rand() function can be called without arguments (in which case the default range will be used) or by specifying min and max parameters.This function always returns an integer.Syntaxrand ( void ) : int rand ( int $min , int $max ) : intParametersSr.NoParameter & Description1minlower limit of range to return a number from. Default is 02maxUpper limit of range to return a number from. Default is getrandmax()Return ValuesPHP rand() ... Read More

Advertisements