Answers for "Associative array in php"

PHP
16

Associative array in php

<?php 
/* 
There are 3 Types of array in php  
1. Indexed arrays - Arrays with a numeric index
2. Associative arrays - Arrays with named keys
3. Multidimensional arrays - Arrays containing one or more arrays

This is the second one - Associative arrays
*/

$age = array("Samy"=>"35", "Naveen"=>"37", "Amit"=>"43");
echo "Mr.Samy is " . $age['Samy'] . " years old.";

?>
Posted by: Guest on June-10-2020
5

how to create an associative array in php

<?php
	$associativeArray = [
        "carOne" => "BMW",
        "carTwo" => "VW",
        "carThree" => "Mercedes"
    ];
    
    echo $associativeArray["carTwo"] . " Is a german brand";
?>
Posted by: Guest on February-18-2020

Code answers related to "Associative array in php"

Browse Popular Code Answers by Language