This repository has been archived by the owner on Sep 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
How can I check that array contain sub array? #103
Labels
Comments
Hello 😄, I think creating an operator for that would be appropriate, like $ruler->getDefaultAsserter()->setOperator('is_subset_of', function (array $needles, array $haystack): bool {
foreach ($needles as $needle) {
if (false === in_array($needle, $haystack)) {
return false;
}
}
return true;
}); then:
Not tested, but it should work. Is it clear? |
Thank you, it work perfect! $ruler->getDefaultAsserter()->setOperator('is_subset_of', function (array $needles, array $haystack) {
foreach ($needles as $needle) {
if (false === in_array($needle, $haystack)) {
if($this->returnError) {
return $needle;
}
return false;
}
}
return true;
}); |
@Commander223 There is no error API yet. You might want to check #41. cc @vonglasow |
@Hywan Ok. Thx for help. |
You're welcome! Feel free to ask anything else! And thanks for using our libraries 😃. |
@Commander223 Are you still living in Kyrgizstan? If yes, can you come on IRC (freenode #hoaproject), I would have some questions for you 😉. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
Need check that some array contain subarray, only way I find create rule for all items in subarray, like "item1 in ['item1', 'item2', 'item3', 'item4', 'item5'] and item2 in ['item1', 'item2', 'item3', 'item4', 'item5'] and item5 in ['item1', 'item2', 'item3', 'item4', 'item5']"
Thanks!
The text was updated successfully, but these errors were encountered: