title: PHP: Searching for specific results in potentially large associative array
body: <p>I have a couple side questions to this but I'll start with what I'm trying to do.</p>
  
  <p>I have an input form where clients will enter some info and their email address, I'm using emails as account identifiers. I want to create an array of emails that it will go through to first check if the email exists in the array, then to check what page to show them...</p>
  
  <p>Something like this:</p>
  
  <pre><code>$client_emails = array(
      'email@ex-one.com',
      'email@ex-two.com' =&gt; 'page_one',
      'email@ex-three.com' =&gt; 'page_two',
      'email@ex-four.com',
      ),
  </code></pre>
  
  <p>So something like this then:</p>
  
  <pre><code>if (!empty($form_email)) { // input field variable
      if (in_array($form_email, $client_emails)) {
          // echo content
      }
  }
  </code></pre>
  
  <p>So with the above being put out there... I want to (1) check if the email exists, then (2) see if the key has a value and if it does then I need to echo that in its own variable to use. Maybe return it in a function?</p>
  
  <p>I'm thinking that I need to have a variable like <code>$client_page</code> and if the function does not return a value to the key (email) then it returns default page.</p>
  
  <p>Pseudo-code:</p>
  
  <pre><code>function($client_page)... if (key exists) {
      if (key has value) {
          return value
      } else {
          return default
      }
  }
  </code></pre>
  
  <p>I came across an interesting setion on the PHP manual that gave an exaple with <code>array_flip()</code>, I'm not sure if that will be useful but it looks like it could be any way:
  <a href="http://php.net/manual/en/function.in-array.php#96198" rel="nofollow noreferrer">http://php.net/manual/en/function.in-array.php#96198</a></p>
  
  <p>I also came across this question on this site, similar but not the same thing:
  <a href="https://stackoverflow.com/questions/24340649/php-searching-multidimensional-associative-array">PHP Searching multidimensional associative array</a></p>
  
  <p>Any ideas?</p>
  
  <hr>
  
  <p>Side questions:</p>
  
  <p>Considering that the emails that I want to store are sensitive information - is there anything I should be doing to protect this more than just have it in a server-side document? Like using php class's? (I don't know anything about using class's and all of that fun stuff)</p>