php tutorial - PHP Datatypes Array - php programming - learn php - php code - php script
- php array stores several values in one single variable.
- php array in PHP is actually an ordered map.
- A map is a type that maps values to keys.

php array code Syntax :
<?php
$arrayname = array("array1","array2","array3");
?>
click below button to copy the code. php tutorial - team
learn php Sample Code : a simple php program
<!DOCTYPE html>
<html>
<head>
<title>Datatype-Array</title>
</head>
<body>
<?php
$wikitechy = array("welcome","wikitechy","Arrays");
var_dump($wikitechy);
?>
</body>
</html>
click below button to copy the code. php tutorial - team
array php examples Code Explanation :

- ($wikitechy) holds the values in a php array as array("welcome","wikitechy","Arrays").
- var_dump($wikitechy); this var_dump() function returns the data type and its values.
Now we need to print the first element of an array.
-
1. First, we pass variable($wikitechy) name with index value[0], that fetchs the first element corresponding to the index value. Output will be welcome.
2.Next pass variable($wikitechy) name with index value[1], that fetchs the second element corresponding to the index value. Output will be wikitechy.
3.Next pass variable($wikitechy) name with index value[2],that fetchs the third element corresponding to the index value. Output will be Arrays.
php tutorials Sample Output :


- array(3) represents the 3 types of php array names i.e. “welcome","wikitechy","Arrays".
- Here in this output, for the 0th array index, the var_dump returns the datatype string with its value welcome which has 7 characters.
- Here in this output, for the 0th array index, the var_dump returns the datatype string with its value welcome which has 7 characters.
- For the 1st array index, the var_dump returns the datatype string with its value wikitechy which has 9 characters.
- For the 2nd array index, the var_dump returns the datatype string with its value Arrays which has 6 characters.