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 - php 7 - php tutorial - php framework tutorial - php examples - php sample code - php basics - php web development - php components - php project - php technology  - learn php - php online - php programming - php program - php code - html code - embedded php in html - web server  - php syntax - php function - variable types

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 :

Code Explanation for Datatype Array In PHP

  1. ($wikitechy) holds the values in a php array as array("welcome","wikitechy","Arrays").
  2. 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.
  3. var_dump($wikitechy); this var_dump() function returns the data type and its values.

php tutorials Sample Output :

output1 for Datatype Array In PHP

output2 for Datatype Array In PHP

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


Related Searches to php datatype array