0

I've two array.

  1. is rules
$rules = [
      "is_www" => true,
      "no_encoding_meta_tag" => true,
      "https_to_http_links" => false,
      "has_render_blocking_resources" => false,
      "low_content_rate" => false,
      "title_too_short" => false,
      "no_description" => false,
      "no_favicon" => false
];
  1. is the array I want to check
$checks = [
      "is_www" => false,
      "no_encoding_meta_tag" => false,
      "https_to_http_links" => true,
      "has_render_blocking_resources" => true,
      "low_content_rate" => false,
      "title_too_short" => false,
      "no_description" => false,
      "no_favicon" => false
];

for this time my code is working fine

        $issue = [];
        foreach ($checks as $v => $i) {
            foreach ($rules as $w => $j) {
                if ($v == $w) {
                    if ($i != $j) {
                        $issue[$v] = $i;
                    }
                }
            }
        }
        var_dump($issue);

and the result is as expected

enter image description here

link to test

what I want to ask is about optimize for large data, how to get the best and fastest way to handle comparasion of two array, if I have much data for $rules and for $check

AdityaDees
  • 1,022
  • 18
  • 39
  • $arraysAreEqual = ($a == $b); // TRUE if $a and $b have the same key/value pairs. $arraysAreEqual = ($a === $b); // TRUE if $a and $b have the same key/value pairs in the same order and of the same types. – jspit Feb 07 '23 at 18:30

0 Answers0