Are there dictionaries in php?

bzupnick picture bzupnick · Jun 27, 2011 · Viewed 161.1k times · Source

For example:

$names = {[bob:27, billy:43, sam:76]};

and then be able to reference it like this:

 $names[bob]

Answer

Jacob picture Jacob · Jun 27, 2011

http://php.net/manual/en/language.types.array.php

<?php
$array = array(
    "foo" => "bar",
    "bar" => "foo",
);

// as of PHP 5.4
$array = [
    "foo" => "bar",
    "bar" => "foo",
];
?>

Standard arrays can be used that way.