An associative array can be created by: main.php Output 1 2 3 4 5 6 <?php// Define an associative array$ages=array("Mark"=>22,"Jeff"=>32,"Mike"=>28); var_dump($ages); which is equivalent to: main.php Output 1 2 3
In an associative array, the keys assigned to values can be arbitrary and user defined strings. In the following example the array uses keys instead of index numbers: Example Run this code» <?php// Define an associative array$ages=array("Peter"=>22,"Clark"=>32,"John"=>28);?> ...
PHP Implode Function PHP Date Function Control Statements PHP If Else If Condition PHP Switch Case PHP Foreach Loop PHP For Loop PHP Loop PHP Array PHP Array PHP Indexed Array PHP Associative Array PHP Multidimensional Array PHP Sorting Arrays PHP Forms PHP GET And POST PHP Advanced PHP Session...
PHP - For Loop PHP - Foreach Loop PHP - While Loop PHP - Do…While Loop PHP - Break Statement PHP - Continue Statement PHP Arrays PHP - Arrays PHP - Indexed Array PHP - Associative Array PHP - Multidimensional Array PHP - Array Functions PHP - Constant Arrays PHP Functions PHP - Functi...
of keys used in our array, which can be either a string or an integer, there are mainly three types in which we create our arrays. The value can be created of any type. Thus, the types can be created as, namely, Numeric or Indexed Array,Associative Array, and Multidimensional Array. ...
$array = {1, 2, 3}; Submit Start Quiz - "PHP basics" Understanding How to Declare an Indexed Array in PHPIn PHP, an indexed array is a type of array where the values are stored and accessed via numerical indexes. The correct way to declare an indexed array in PHP is shown below:...
Quiz Time: Test Your Skills! Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge. PHP basics ❮ PrevNext ❯ Submit Do you find this helpful?