2018-07-05 09:48
浏览 91


I have a multidimensional array

Simple example array

[0]=>array(2) {
["slug"]=>string(12) "exampleslug1"
["tax"]=>string(11) "exampletax1"}
[1]=>array(2) {
["slug"]=>string(12) "exampleslug2"
["tax"]=>string(11) "exampletax2"}
[2]=>array(2) {
["slug"]=>string(12) "exampleslug2"
["tax"]=>string(11) "exampletax3"}

Now i want to check another multidimensional array for both values.

So for example. I want to check if the slug is "exampleslug2" and the tax = "exampletax2" So in this case it should return false/true/false.

Ive tried in_array but i can't seem to get that to work for multidimensional. Can anyone help me out with a solution for checking multiple values in the multidimensional array to be the same as in a second multidimensional array.

If it try something like

if (!in_array($termSlug, $externalTermSlugs['slug']) && !in_array($termTax, $externalTermSlugs['tax']) ) {}

It adds everything multiple times, what i want to have is that it adds everything once unique and doesn't overwrite if it already exists.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题