Associative Array
Associative Array
<?php
//associative array:-
$a = array (
"mac"=> 75000,
"dell"=> 50000,
"acer"=> 47000
);
//when we change the value then we type $variable then [bracket] = change value.
$a["dell"] = 57000;
//print_r is for testing array value and key.
echo "<pre>";
print_r ($a)."<br>";
echo "</pre>";
//This one you call the key. The output comes only value not keyword (mind this).
echo $a["acer"]."<br>";
echo $a["mac"]."<br>";
echo $a["dell"];
//Associative array bahat jyada use hota hai database ke sath
?>
Output
Array
(
[mac] => 75000
[dell] => 57000
[acer] => 47000
)
4700075000
57000
Comments
Post a Comment