Tag Archives — PHP

PHP String Functions (All on One Page)

addcslashes() — Quote string with slashes in a C style addslashes() — Quote string with slashes bin2hex() — Convert binary data into hexadecimal representation chop() — Alias of rtrim chr() — Generate a single-byte string from a number chunk_split() — Split a string into smaller chunks convert_cyr_string() — Convert from one Cyrillic character set to […]

How Can I Strip all Whitespace Characters in a String in PHP?

Many times, the strings that you are manipulating in a PHP project will have extra spaces that need to be removed. For instance, you might want to replace multiple spaces with a single space or you might want to get rid of all the whitespace in a string. Similarly, you might be planning on stripping […]

How Can I Resize an Image Programmatically in PHP?

If you are working on a website or project which deals with images, there will most probably come a time when you will have to programmatically resize those images. Maybe you have to create three different sizes of the same image to serve on different devices. Maybe you need to resize images that your users […]

How Can I Remove or Delete Empty Array Elements in PHP?

Many times, when working on a PHP project, you deal with an array which has some unwanted or empty array elements. This is especially true if you have no control over the values populated into the array. For example, you might have to store user input into an array and some of that input might […]

How can I Delete an Element from an Array in PHP?

Let’s say you have an array and you want to delete one or more elements from that array using PHP. Maybe you have to delete an element with a specific value or maybe you have to delete multiple consecutive elements. In this article, you will learn about different inbuilt PHP functions that can help you […]

PHP DatePeriod Class Methods

DatePeriod class Methods in PHP Function Name Function Description DatePeriod::__construct() Creates a new DatePeriod object DatePeriod::getDateInterval() Gets the interval DatePeriod::getEndDate() Gets the end date DatePeriod::getRecurrences() Gets the number of recurrences DatePeriod::getStartDate() Gets the start date PHP DatePeriod::__construct() Method What does DatePeriod::__construct() do? The PHP DatePeriod::__construct() method creates a new DatePeriod object. PHP DatePeriod::__construct() Syntax PHP […]

PHP DateTime Class Methods

DateTime class Methods in PHP Function Name Function Description DateTime::add() Adds an amount of days, months, years, hours, minutes and seconds to a DateTime object DateTime::__construct() Returns new DateTime object DateTime::createFromFormat() Parses a time string according to a specified format DateTime::createFromImmutable() Returns new DateTime object encapsulating the given DateTimeImmutable object DateTime::getLastErrors() Returns the warnings and […]

Arbitrary Precision Maths Functions in PHP (BC Math)

Arbitrary Precision Maths Functions in PHP Function Name Function Description bcadd() Add two arbitrary precision numbers bccomp() Compare two arbitrary precision numbers bcdiv() Divide two arbitrary precision numbers bcmod() Get modulus of an arbitrary precision number bcmul() Multiply two arbitrary precision numbers bcpow() Raise an arbitrary precision number to another bcpowmod() Raise an arbitrary precision […]

Miscellaneous Maths Functions in PHP

Miscellaneous Maths Functions in PHP Function Name Function Description deg2rad() Converts the number in degrees to the radian equivalent hypot() Calculate the length of the hypotenuse of a right-angle triangle intdiv() Integer division lcg_value() Combined linear congruential generator pi() Get value of pi rad2deg() Converts the radian number to the equivalent number in degrees PHP […]

Numerical Functions in PHP

Numerical Functions in PHP Function Name Function Description abs() Absolute value ceil() Round fractions up floor() Round fractions down fmod() Returns the floating point remainder (modulo) of the division of the arguments is_finite() Finds whether a value is a legal finite number is_infinite() Finds whether a value is infinite is_nan() Finds whether a value is […]

0%