Array Function in PHP

In this article I explain the PHP array function.
  • 1705

PHP array Function

The array() function creates an array. The array function have two parameters (key and values). If you not specifies key value, an integer key is automatically generated, starting at 0 and increase one for each value.

Syntax

array (key =>value)

Parameter in array function

It takes two parameters; they are:

Parameter Description
key It is optional parameter that specifies the key , of type numeric or string.
value It specifies the value.

Example of array function

<?php

$fruits=array("Apple","Banana","Raspberry","Apricot");

echo "<pre>";

print_r($fruits);

?>

Output

array-function-in-php.jpg

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.