title: PHP Count Number of Times A String Appears As A Value Inside An Array
body: <p>So I looked around here for a bit but cant seem to get this right, so I am forced to make a new post. I gave it an effort! Don't hurt me. </p>
  
  <p><strong>Sample Array:</strong></p>
  
  <pre><code>$ndata = Array
  (
      [ARMOR_HEAD] =&gt; Andariel's Visage
      [ARMOR_TORSO] =&gt; Blackthorne's Surcoat
      [ARMOR_FEET] =&gt; Illusory Boots
      [ARMOR_HANDS] =&gt; Gauntlets of Akkhan
      [ARMOR_SHOULDERS] =&gt; Pauldrons of Akkhan
      [ARMOR_LEGS] =&gt; Blackthorne's Jousting Mail
      [ARMOR_BRACERS] =&gt; Nemesis Bracers
      [ARMOR_MAINHAND] =&gt; Gyrfalcon's Foote
      [ARMOR_OFFHAND] =&gt; Jekangbord
      [ARMOR_WAIST] =&gt; Blackthorne's Notched Belt
      [ARMOR_RRING] =&gt; Ring of Royal Grandeur
      [ARMOR_LRING] =&gt; Stone of Jordan
      [ARMOR_NECK] =&gt; Kymbo's Gold
  )
  
    $count = count(preg_grep('Akkhan', $ndata));
    print_r($count);
  </code></pre>
  
  <p>So this is only returns 1 instead of 2. I also tried <code>array_search()</code>, but that simply returns a the first found with its key. Or <code>in_array</code> but that is just boolean I guess.. Is there a better way to go about this?</p>