coercive / arraypath
Coercive 实用 ArrayPath
0.0.3
2022-10-30 15:05 UTC
Requires
- php: >=7.4
This package is auto-updated.
Last update: 2024-08-29 04:09:14 UTC
README
- 像文件路径一样跨表格。
获取
composer require coercive/arraypath
类
use Coercive\Utility\ArrayPath\ArrayPath; # EXAMPLE $example_array = [ '1' => [ '2' => [ '3' => [ 'content' ] ] ] ]; # INIT OBJECT $handler = ArrayPath::init($example_array); # RETRIEVE CONTENT $content = $handler->get('1.2.3'); $content = $handler->get('1.2.3.4', '-- null or not exist --'); # VERIFY PATH EXIST if($handler->has('1.2.3')) { // ... } # OR get and check in same time $content = $handler->get('1.2.3.4', null, $exist); if(!$exist) { // ... } # SET VALUE $handler->set('1.2.3', ['new-content']); # DELETE PATH $handler->delete('1.2.3'); # RESET $handler->reset(); # OPTION : custom separator $handler->setSeparator('@'); $content = $handler->get('1@2@3');