PHP Array Function Example

03-Apr-2023

.

Admin

Hello Friends,

Now let's see example of how to use array in php function. This is a short guide on php if array function. We will use array function in php. PHP provides various array functions to access and manipulate the elements of array. PHP array() function creates and returns an array. It allows you to create indexed, associative and multidimensional arrays.

Here i will give you example of how you can check array function in php file.

Syntax 1 for indexed arrays:


array(value1, value2, value3, etc.)

Syntax 2 for associative arrays:

array(key=>value,key=>value,key=>value,etc.)

Example

<!DOCTYPE html>

<html>

<head>

<title>Array Function in PHP - NiceSnippets.com?</title>

</head>

<body>

$cars=array("Volvo","BMW","Toyota");

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

</body>

</html>

Output:

I like Volvo, BMW and Toyota.

It will help you....

#PHP 8

#PHP