1. Go to this page and download the library: Download kohkimakimoto/earray library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$earray = new EArray(
array(
"foo" => array(
"foo2" => array(
"foo3",
"foo4",
),
"foo2-1" => "foo5",
),
"bar",
"hoge",
)
);
// You can get a value from a nested array.
$earray->get("foo/foo2-1"); # "foo5".
$earray->get("foo"); # EArray(array("foo2" => array("foo3","foo4",),"foo2-1" => "foo5"))
$earray->get("foo")->get("foo2-1"); # "foo5".
$earray->get("foo")->toArray(); # array("foo2" => array("foo3","foo4",),"foo2-1" => "foo5")
// You can change a delimiter by the third argument.
$earray->get("foo.foo2-1", null, "."); # "foo5"
// You can set a value to a nested array.
$earray->set("foo/foo2-1", "foo5-modify");
$earray->get("foo/foo2-1"); # "foo5-modify".
// You can delete a value from a nested array.
$earray->delete("foo/foo2-1");
$earray->get("foo/foo2-1"); # null
// You can check a value existing from a nested array.
$earray->exists("foo/foo2-1") # false
// by the constructor's second argument.
$earray = new EArray(array("foo" => array("bar" => "value")), ".");
$earray->get("foo.bar")); // "value"
// by the setDelimiter method.
$earray->setDelimiter("-");
$earray->get("foo-bar")); // "value"