Tag learn php in y minutes

PHP Global Variables – Superglobals

Superglobals were introduced in PHP 4.1.0, and are built-in variables that are always available in all scopes. PHP Global Variables – Superglobals Some predefined variables in PHP are “superglobals”, which means that they are always accessible, regardless of scope –…

PHP Multidimensional Arrays

In the previous pages, we have described arrays that are a single list of key/value pairs. However, sometimes you want to store values with more than one key. For this, we have multidimensional arrays.

PHP Sorting Arrays

The elements in an array can be sorted in alphabetical or numerical order, descending or ascending. PHP – Sort Functions For Arrays In this chapter, we will go through the following PHP array sort functions: sort() – sort arrays in…

PHP Delete Array Items

Remove Array Item To remove an existing item from an array, you can use the array_splice() function. With the array_splice() function you specify the index (where to start) and how many items you want to delete. Example Remove the second…

PHP Add Array Items

Add Array Item To add items to an existing array, you can use the bracket [] syntax. Example Add one more item to the fruits array: $fruits = array(“Apple”, “Banana”, “Cherry”); $fruits[] = “Orange”;

PHP Update Array Items

Update Array Item To update an existing array item, you can refer to the index number for indexed arrays, and the key name for associative arrays. Example Change the second array item from “BMW” to “Ford”: $cars = array(“Volvo”, “BMW”,…

PHP Access Arrays

Access Array Item To access an array item, you can refer to the index number for indexed arrays, and the key name for associative arrays. Example Access an item by referring to its index number: $cars = array(“Volvo”, “BMW”, “Toyota”);…

PHP Create Arrays

Create Array You can create arrays by using the array() function: Example $cars = array(“Volvo”, “BMW”, “Toyota”); You can also use a shorter syntax by using the [] brackets: Example $cars = [“Volvo”, “BMW”, “Toyota”];