php create associative array with keys code example
Example 1: how to create an associative array in php
<?php
$associativeArray = [
"carOne" => "BMW",
"carTwo" => "VW",
"carThree" => "Mercedes"
];
echo $associativeArray["carTwo"] . " Is a german brand";
?>
Example 2: how to create associative array in php
<?php
$a = array('a','b','c');
$b = ['a','b','c'];
$c = array(
'keyOne'=>'valueOne',
'keyTwo'=>'valueTwo'
);
$d = [
'keyOne'=>'valueOne',
'keyTwo'=>'valueTwo'
];
$c = array(
'keyOne'=>array('a','b','c'),
'keyTwo'=>array('a'=>'1','b'=>'2')
);
$d = [
'keyOne'=>['a','b','c'],
'keyTwo'=>['a'=>'1','b'=>'2']
];
?>
Example 3: php associative array
Array
(
[email] => abeermanchanda00@gmail.com
[password1] => chess
[passcheck1] => on
[submit] => Login
)