Is there Dictionary Object in PHP
-
Hi guys; I wish to store KeyValuePair collection as I do in C# or VB.NET. Is there a way to achieve this in PHP and how? Thanks for your cordial supports.
-
Hi guys; I wish to store KeyValuePair collection as I do in C# or VB.NET. Is there a way to achieve this in PHP and how? Thanks for your cordial supports.
You can do that using an array:
<?php
$dict = array('a' => 1, 'b' => 2, 'z' => 0);
$dict['c'] = 5;
$dict['a more complex value'] = array('X' => 'OK');foreach($dict as $key => $value)
echo "$key : $value<br />\n"; -
You can do that using an array:
<?php
$dict = array('a' => 1, 'b' => 2, 'z' => 0);
$dict['c'] = 5;
$dict['a more complex value'] = array('X' => 'OK');foreach($dict as $key => $value)
echo "$key : $value<br />\n";Thanks Graham. Your solution works. Thanks.