epiclesys / value-matcher
1.0.3
2024-09-06 23:13 UTC
Requires (Dev)
- phpunit/phpunit: ^11.3
- symfony/var-dumper: ^7.1
This package is auto-updated.
Last update: 2024-09-06 23:13:46 UTC
README
A simple PHP library for searching json values inside json or sub-arrays inside arrays.
安装
您可以通过 Composer 安装此包
composer require epiclesys/value-matcher
在另一个 json 中查找 json 值
比如说,我们需要检查这个 json 值
{ "key" : ["value"] };
是否在这里的某个地方被包含
{
"level9": {
"finalLevel": "reached",
"stillGoing": true,
"data" : { "key" : ["one", 2, "value"] }
}
}
用法
<?php require __DIR__ . '/vendor/autoload.php'; use Epiclesys\ValueMatcher\JsonMatcher; $needle = '{ "key" : ["value"] }'; $haystack = ' { "level9": { "finalLevel": "reached", "stillGoing": true, "data" : { "key" : ["one", 2, "value"] } } }'; JsonMatcher::contains($needle, $haystack); // true
同样适用于匹配另一个数组中的数组值
ArrayMatcher::contains($needle, $haystack); // true
This project is licensed under the MIT License.