Practical solutions

PHP Howtos How-To Guides

Solve the problem. Keep building. Collection of PHP how-to articles

Find the answer you need

Browse practical solutions, grouped by the task you're working on.

__COUNT__ entries on this page

How to Return User Quota With PHP in LinuxThis tutorial teaches how to return user Quota with PHP in Linux OS. How to Get the Current Date and Time in PHPThis article introduces how to get the current date and time in PHP. It includes date() function, time() function, date_default_timezone_set() function, format() function and setTimezone() function. How to Write Into a File in PHPThis article introduces how to write into a file in PHP. It includes file_put_contents() function, fopen() function, fwrite() function and fclose() function. How to Check if a String Starts With a Specified String in PHPThis article introduces how to check if a string starts with a specified string in PHP. It includes substr() function, strpos() function and strncmp() function How to Use cURL to Get JSON Data and Decode JSON Data in PHPThis article introduces how to use cURL to get JSON data and decode JSON data in PHP. It includes curl_init() function, curl_setopt() function, curl_exec() function and curl_close() function. How to Parse a JSON File in PHPThis article introduces how to parse a JSON file in PHP. It includes file_get_contents() function. How to Convert One Date Format to Another in PHPThis article introduces how to convert one date format to another in PHP. It includes date() function, strtotime() function, createFromFormat() function and format() function. How to Show a Number to Two Decimal Places in PHPThis article introduces how to show a number to two decimal places in PHP. It includes number_format() function, round() function and sprintf() function How to Remove Empty Array Elements in PHPThis article introduces how to remove empty array elements in PHP. It includes array_filter() function, array_diff() function and unset() function. How to Delete an Element From an Array in PHPThis article introduces how to delete an element from an array in PHP. It includes unset() function, array_splice() function and array_diff() function How to Convert a Date to a Timestamp in PHPThis article introduces how to convert a date to a timestamp in PHP. It includes strtotime() function, strptime() function, getTimestamp() function and format() function. How to Get the Current Year in PHPThis article introduces how to get the current year in PHP, for example, date() function, strftime() function and by using the DateTime object. How to Get the Last Character of a String in PHPThis article introduces how to get the last char of a string in PHP. It includes substr() function, direct string access method and for loop method. How to Find the Foreach Index in PHPThis article introduces how to find the foreach index in PHP. How to Convert DateTime to String in PHPDifferent ways of converting DateTime to string using PHP functions, like Using format() of DateTime class, using date_format() method. How to Calculate the Difference Between Two Dates Using PHPCalculating the differences between two dates using PHP version less than 5.3 and more than 5.3 How to Create a Folder if It Doesn't Exist in PHPThis article introduces how to create a new folder programmatically in PHP if it doesn't exist. How to Determine the First and Last Iteration in a Foreach Loop in PHPDifferent ways of getting the first and last item in a foreach() loop using different versions of PHP, including counter in all PHP versions and array_key_first() and array_key_last() from PHP 7.3 How to Properly Format a Number With Leading Zeros in PHPDifferent ways of formatting a number with leading zeros using several functions in PHP. How to Create a PHP Function With Multiple ReturnsPossibility of having multiple returns in a PHP function using several approaches How to Remove All Spaces Out of a String in PHPThis article introduces how to strip all spaces out of a string in PHP. It includes str_replace() function and preg_replace() function. Examples on Using the SoapClient in PHPIn this article, we present six examples that show you how to work with WSDL files using PHP SoapClient. Before that, we'll explain how you can get the function and types from a web service. This is a must if you want to use the web service. PHP Warning Invalid Argument Supplied for foreach()This tutorial demonstrates how to fix the PHP warning invalid argument supplied for foreach(). Question Mark Symbol in PHPThis tutorial introduces the question mark ternary operator and discuss its use in PHP.