How-to articles, tricks, and solutions about PHP

How to Convert MySQL Data to JSON with PHP

If you wonder how to find a proper way of converting MySQL data to JSON format using PHP, then you are in the right place. Read on and check the example.

How to convert seconds to time format?

To convert seconds to a time format in PHP, you can use the date function and specify the format you want to use.

How to Count All the Array Elements with PHP

While working with arrays, it is commonly necessary to count all its elements. This snippet will discover two helpful functions that will help you do that.

How to count and group by in yii2

In Yii2, you can use the count() and groupBy() methods in the query builder to count and group the results of a query, respectively.

How to count days between two dates in PHP?

You can use the DateTime class in PHP to calculate the number of days between two dates.

How to Count the Pages in a PDF File with PHP

PHP provides a range of extensions and functions for getting the number of pages in a PDF document. Let’s check out the most efficient ones, here.

How to create a foreign key in phpmyadmin

To create a foreign key in PHPMyAdmin, follow these steps:

How to Create a jQuery Ajax Post with PHP

Here, we will share with you how to create a jQuery Ajax post request with PHP. Just check out the examples and choose the one that suits your needs best.

How to Create a New Line in PHP

In this snippet, we are going to describe how to create a new line with the help of the PHP arsenal. Go ahead and learn how to do it easily.

How to create and download a csv file from php script?

To create and download a CSV file from a PHP script, you can use the following steps:

How to Create and Parse JSON Data with PHP

JSON is a data-interchange format, which can be generated and parsed by PHP or other programming languages. See how to create and parse JSON data by PHP.

How to create new property dynamically

In PHP, you can create a new property for an object dynamically by using the magic method __set.

How to Create URL Slug from String in PHP

Here is a short tutorial that will represent to you the way of creating a URL slug from string with PHP. It should be an essential part of any website.

How to create virtual column using MySQL SELECT?

To create a virtual column using a MySQL SELECT statement, you can use the AS keyword to assign a name to an expression in the SELECT statement.

How to Deal With Undefined Offset Error in PHP

Here is a snippet that will help you to deal with a common PHP undefined offset error. Here, you will find three methods that help to avoid such an error.

How to decode Unicode escape sequences like "\u00ed" to proper UTF-8 encoded characters?

In PHP, you can use the utf8_decode() function to decode a string that contains Unicode escape sequences.

How to Delete an Element from an Array in PHP

In this short tutorial, you will find the most proper solution to the commonly asked question by programmers: how to delete an element from an array.

How to delete multiple records using Laravel Eloquent

You can use the destroy() method in Laravel Eloquent to delete multiple records.

How to Detect Browser with PHP

Browser detection is used to determine the web browser a visitor is using and to serve browser-appropriate content to the visitor. Know how to do it with PHP.

How to Determine the First and Last Iteration in a Foreach loop?

In this snippet, we are going to figure out how to successfully determine the first and last iteration in a foreach loop with the help of PHP.

How to disable output buffering in PHP

In PHP, you can disable output buffering by calling the ob_end_flush() function or flush() function.

How to disable registration new users in Laravel

To disable registration of new users in Laravel, you can remove the registration routes from the web.php file in the routes folder.

How to display a date as iso 8601 format with PHP

You can use the date() function in PHP to display a date in ISO 8601 format.

How to Display PHP Errors

Often errors occur while executing a PHP application. Read this snippet to learn how to overcome difficulties and display such errors with the help of PHP.