Arrays in PHP. Create, add, change. Code example open

Arrays in PHP. Create, add, change. Code example

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

An array in PHP is an ordered mapping that maps a value to a key.

Create an array:

$array = array('apple', 'samsung', 'nokia');
//or
$array = ['apple', 'samsung', 'nokia'];

Show the element of the array (starting with 0):

echo $array[0];// apple

Change the element of the array:

$array[0] = 'LG';

Add an element to the array:

$array[] = 'Xiaomi';

Remove the element from the array:

unset($array[1]);//// delete samsung
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation