title: Escape brackets within string
body: <p>I need to escape brackets within a file name. Currently I do this as follows:</p>
  
  <pre><code>$string = 'folder1/folder2/foldera/abc/myFile(2).jpg';
  
  str_replace(')', '\)', str_replace('(', '\(', $string));
  
  echo $string;
  
  // outputs: folder1/folder2/foldera/abc/myFile\(2\).jpg 
  </code></pre>
  
  <p>It is inefficient as this is executed within a loop of hundreds of results. Is there a better, cleaner more efficient way of achieving this?</p>