How to use array in PHP
In this article, I will explain how the array() function can be used in PHP.
array() function in PHP
-
array() creates an array, with keys and values.
-
In array(), If you want to skip the keys when you specify an array.
-
In array(), key is generated automatically in integer type, starting at 0 and increases by 1 for each value.
-
In array(), the parameters can be given an index with the => operator
Syntax
Parameter
Key key is the optional parameter. the key is determine in two type numeric or string. If not set, an integer key is generated, starting at 0.
value value is the Required parameter. Specifies the value.
Example
The following example show to how the array() function can be used in PHP.
<h3 style="color: tomato;">array example in PHP</h3>
<?php
$i=array("1"=>"Aman <br/>","2"=>"Ravi <br/>","3"=>"Manish <br/>","4"=>"Arvind <br/>");
print_r($i);
?>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here