title: How to implement REGEXP in foreach the right way?
body: <p><strong>Hello,
  How to add regexp the right way in this code in order to search for exact word in database?</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$condition = '';
  $name = "he  is mad";
  $query = explode(" ", $name);
  foreach($query as $text) {
      $condition .= "test LIKE '%".mysqli_real_escape_string($conn, $text)."%' OR ";
  }
  
  $condition = rtrim($condition, " OR ");
  
  $sql_query = "SELECT * FROM test WHERE " . $condition;
  $result = mysqli_query($conn, $sql_query);
  if ($result-&gt;num_rows &gt; 0) {
      echo "1";
  } else {
      echo "0";
  }
  $conn-&gt;close();</code></pre>
  </div>
  </div>
  </p>
  <p><strong>I want to add this to the php code</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>SELECT 
      *
  FROM
      `table`
  WHERE
      Description regexp '(^|[[:space:]])pen([[:space:]]|$)';</code></pre>
  </div>
  </div>
  </p>
  <p><strong>It only works with me like this without foreach:</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>    $sql_query = "SELECT * FROM test WHERE test regexp '(^|[[:space:]])$condition([[:space:]]|$)'";</code></pre>
  </div>
  </div>
  </p>