thoma127/dict

一个简单的PHP类,用于实现Python字典类似的功能。

v0.1.3 2018-02-18 15:00 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:20:08 UTC


README

这是一个简单的PHP类,用于模拟Python字典的一些行为。

具体来说,可以通过键引用轻松存储和检索任意数据。

用法

$data = ["foo" => "bar"];
$dict = new \UMN\CEHD\Dict\Dict($data);

$foo = $dict->get("foo"); // will be "bar"
$baz = $dict->get("baz"); // will be null
$json = $dict->toJSON(); // will be {"foo":"bar"} (string)

$array = $dict->toArray();

var_dump($array);

array(1) {
  'foo' =>
  string(3) "bar"
}