title: Search value in php array and get all keys
body: <p>Is there any better (= quicker ) solution to get all keys of value in array than foreach loop with if?</p>
  
  <pre><code>$array = array('apple', 'orange', 'pear', 'banana', 'apple',
  'pear', 'kiwi', 'kiwi', 'kiwi');
  </code></pre>
  
  <p>print_r($array); will give me:</p>
  
  <pre><code>Array ( [0] =&gt; apple [1] =&gt; orange [2] =&gt; pear [3] =&gt; banana [4] =&gt; apple [5] =&gt; pear [6] =&gt; kiwi [7] =&gt; kiwi [8] =&gt; kiwi )
  </code></pre>
  
  <p>array_search("kiwi", $array); will give me <strong>6</strong></p>
  
  <p>But I want all keys of kiwi. So I want <strong>6,7,8</strong>. In this case.</p>
  
  <p>Bruteforce search loop:</p>
  
  <pre><code> $searchObject = "kiwi";
   $keys = array();
   foreach($array as $k =&gt; $v) {
   if($v == $searchObject) $keys[] = $k; 
  }
  </code></pre>