Associative array/Creation: Difference between revisions

Content added Content deleted
m (Categorizing programming examples)
(added php example)
Line 93: Line 93:


let quux = try Hashtbl.find hash "quux" with Not_found -> some_value;;
let quux = try Hashtbl.find hash "quux" with Not_found -> some_value;;

==[[PHP]]==
[[Category:PHP]]

$array = array();
$array['foo'] = 'bar';
$array['bar'] = 'foo';
echo($array['foo']); // bar
echo($array['moo']); // Undefined index

===Iterate over key/value===
foreach($array as $key => $value)
{
echo('Key: '.$key.' Value: '.$value);
}


==[[Perl]]==
==[[Perl]]==