Having an array like [1]
$arr = array(
array(
"ignoreMe" => "123",
"checkMe" => "value",
),
array(
"ignoreMe" => "456",
"checkMe" => "value",
),
);
I'd like to check if special keys (here the key checkMe
) of the inner array have the same value.
If all keys have the same value, then I'd like to remove the key from the inner array. (from all arrays)
But when having an array like [2]
$arr = array(
array(
"ignoreMe" => "123",
"checkMe" => "value",
),
array(
"ignoreMe" => "456",
"checkMe" => "value",
),
array(
"ignoreMe" => "789",
"checkMe" => "foo",
),
);
All keys should stay intact.
How would I do this with this complex validator? (Link https://github.com/Respect/Validation)
Expected result of [1] is
$arr = array(
array(
"ignoreMe" => "123",
),
array(
"ignoreMe" => "456",
),
);
[2] should not be touched
Here is what has been tried:
$validator = v::arr()->each(v::key("check", v::equals('value')));