title: preg_match() expects parameter 2 to be string, array given
body: <p>array search is returning error.</p>
  
  <p>Suppose i have an arrays like so ---</p>
  
  <pre><code>[1] =&gt; Array
      (
          [id] =&gt; 11
          [category] =&gt; phone cases
          [country] =&gt; sweden
          [sale_price] =&gt; 90,99
          [price] =&gt; 120
          [currency] =&gt; sek
          [vat] =&gt; 19
          [product_name] =&gt; "iphone 6 plus" case transparent
          [description] =&gt; transparent case for iphone 6 plus
      )
  
  [2] =&gt; Array
      (
          [id] =&gt; 13
          [category] =&gt; shoes
          [country] =&gt; sweden
          [sale_price] =&gt; 180,99
          [price] =&gt; 200
          [currency] =&gt; sek
          [vat] =&gt; 19
          [product_name] =&gt; blue platform shoes
  </code></pre>
  
  <p>Now i am trying to search something from this array, basically i am trying to find it from the $all_data,  <strong>['product_name']</strong> field</p>
  
  <pre><code>$data = 'plus'; // what i want to search
  $search = $this-&gt;my_array_search($all_data, $data);
  
  
  function my_array_search($array, $string) {
      $pattern = preg_replace('/\s+/', ' ', preg_quote($string));
      return array_filter($array, function ($value) use($pattern) {
          return preg_match('/' . $pattern . '/', $value) == 1;
      });
  }
  </code></pre>
  
  <p>but it is keep returning me an error --</p>
  
  <blockquote>
    <p>preg_match() expects parameter 2 to be string, array given</p>
  </blockquote>
  
  <p>What i am doing wrong, do any one knows how to solve this problem !!</p>