A simple PHP library for searching json values inside json or sub-arrays inside arrays.
You can install this package via Composer:
composer require epiclesys/value-matcherMach json values inside other json
Say we need to check if this json value
{ "key" : ["value"] };
is contained somewhere here
{
"level9": {
"finalLevel": "reached",
"stillGoing": true,
"data" : { "key" : ["one", 2, "value"] }
}
}
Usage
<?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); // trueSimilarly works for matching array values inside another array
ArrayMatcher::contains($needle, $haystack); // trueThis project is licensed under the MIT License.