PHP

3 Ways to Add Leading Zero before a Single Digit Using PHP

Here, we’re sharing the three ways to add leading zeros before a single digit number using PHP. The default PHP functions, we’re going to use are sprintf and str_pad....

2 Ways to Create a Dropdown List of Timezones Using PHP

Today, we are going to share the ways to generate a dropdown list of Timezones using PHP. I swear, I won’t go old school when I used to manually store all the timezones list...

2 Ways to Copy a File from One Folder to Another with PHP

Find out the two ways to copy a file from one folder to another folder using PHP. We’re going to use copy() and shell_exec(). copy() crayon-599bbf9e6bfd3849644756/ shell_exec()...

PHP Regular Expression: Remove Spaces from a String

The following PHP regular expression code will help you to remove multi-spaces, from the string’s start and end. The first line of preg_replace() will convert all multi-spaces...

PHP: 4 Ways to Get Current Year

Find out the four ways to get current year using PHP. Here, we are going to use date(), DateTime, strftime() and gmdate(). date() The PHP’s date function displays the local...

PHP: 2 Ways to Get File Name from a Full Path

In this tutorial, you are going to find the two ways to get the filename from a full path using PHP. basename() crayon-599bbf9e6ce9f048678300/ pathinfo() Note: pathinfo() is...

5 Ways To Get First Key of an Array Using PHP

Find out the five ways to get first key of an array using PHP. The functions used in this tutorial are: key(), reset(), array_flip(), current(), list(), each(), array_shift(),...

2 Ways To Convert Timestamp to Time Ago Using PHP

If you want to convert a timestamp to time ago using PHP, e.g., 3 days ago, 1 year ago, then use the two methods below to convert a timestamp to time ago. Table of Contents Method...

4 Ways to Remove Empty Array Elements Using PHP

You’ll find the four ways to remove empty array elements using PHP down below. The first and second method is the best approach to remove empty elements from an array with PHP....

6 Ways to Display Date Range between Two Dates Using PHP

We have created six methods to display date range between two dates using PHP for this tutorial. The date range will be in the form of an array. Method 1 Method 2 Method 3 Method...