title: Preg_replace Pattern Variable
body: <p>I have a list of names and I'm using preg_replace to make a certain part of those names bold. I was using str_replace but I needed a limit on it.</p>
  
  <p>However I'm getting the error "Delimiter must not be alphanumeric or backslash". After some research I found out that it's happening because I'm missing slashes on my pattern variable. </p>
  
  <p>However I've been trying and I can't get it right and I'm not finding any example like mine. Thank you for your help.  </p>
  
  <pre><code>while($row = $result-&gt;fetch_array()) {
          $name = $row['name'];
  
      $array = explode(' ',trim($name));
      $array_length = count($array);
  
      for ($i=0; $i&lt;$array_length; $i++ ) {
          $letters = substr($array[$i], 0, $q_length);
          if ($letters = $q) {
          $bold_name = '&lt;strong&gt;'.$letters.'&lt;/strong&gt;';
          $final_name = preg_replace($letters, $bold_name, $array[$i], 1);
          $array[$i] = $final_name; } 
      }
  </code></pre>