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 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 Convert a String to a Number in PHPThis article introduces how to convert a string to a number in PHP. It includes inval() function, settype() function and explicit type casting. How to Convert an Integer Into a String in PHPThis article introduces how to convert an integer to a string in PHP. 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 Pass Variables to the Next Page in PHPDifferent approaches on how to pass variables to the next page using PHP, like using GET and POST through HTML form, and using session and cookie. 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. PHP Variable in StringThis tutorial demonstrates how to mix a PHP variable with a string Difference Between the == and the === Comparison Operators in PHPThis tutorial introduces the difference between the double equals and triple equals comparison operators in PHP. One Line if Statement in PHPThis article introduce the one line if statement in PHP. Maximum Upload Size in PHPToday's post will cover maximum upload size in PHP. PHP ini_set Memory LimitWe will perform two methods to set the memory limit in php. Then we will use a PHP script to set the memory limit in PHP. PHP Zip ExtensionThis tutorial demonstrates how to install and use ZIP Extension in PHP. Undefined Index With PHP PostThis article teaches you four solutions to undefined index in a PHP post array. The solutions will use isset(), array_key_exists(), in_array(), and the Null coalescing operator. First, we'll reproduce the error and then we'll show you the solutions. Meanwhile, in PHP 8, undefined index is the same undefined array key.