title: Warning: Undefined array key PHP when checking for a key in an IF statement (not $_GET or $_POST)
body: <pre><code>    if (!$pairs['width'] &amp;&amp; !$pairs['img_height'])
          $pairs['width'] = 200;
      $pairs['figure'] = $item['image'];
      if (!$pairs['url'])
          $pairs['url'] = $item['URL'];
      if (!$pairs['pop'])
          $pairs['pop'] = $item['description'];
      // I got confused sometimes... put in support for BOTH options
      if (!$pairs['caption'])
          $pairs['caption'] = $pairs['write'];
      // Worst case, just list the title of the item
      if (!$pairs['caption'])
          $pairs['caption'] = $item['title'];
      if (strpos($pairs['url'],'amazon.com') !== false)
          $pairs['caption'] .= '&lt;br/&gt;(&lt;a href='.$pairs['url'].'&gt;See online!&lt;/a&gt;)';
      else
          $pairs['caption'] .= '&lt;br/&gt;(&lt;a href='.$pairs['url'].'&gt;Learn more&lt;/a&gt;)';
  </code></pre>
  <p>The above code snippet is in a function where I send an array of controls/options some of which might be blank or not present. For the cases where the index of the passed array is not set, it's throwing an error. I'm aware that PHP doesn't like this method, but it works fine so long as PHP just treats a non-existant array index as false for the purposes of an if statement.</p>
  <p>Is there a simple way of solving this problem without having to predefine the entire array and all it's keys? I suspect this is a problem with updating to PHP 8 and am tempted to turn off warnings, but would rather do it &quot;right&quot; (unless that means predefining everything).</p>
  <p>This is triggering an error on any IF statements that test arrays this way.</p>