title: How to delete dollar signs($) from a PHP variable only if the dollar signs are surrounding a word
body: <p>I want to delete any dollar sign($) from a PHP variable <strong>only</strong> if it surrounds a word.</p>
  
  <p>I know how to replace every $ with empty space to look like is deleted, for example:</p>
  
  <pre><code>  &lt;?php 
  
        $string = 'Hello $George$';
        $string = str_replace('$', '', $string);
        echo $string; // Prints: Hello George
  
  
     ?&gt;
  </code></pre>
  
  <p>But the code above is also removing $ that are not surrounding a word, for example:</p>
  
  <pre><code>&lt;?php 
  
        $string = 'Hello $George$, are you $ok?';
        $string = str_replace('$', '', $string);
        echo $string; // Prints Hello George, are you ok?
  
     ?&gt;
  </code></pre>
  
  <p>I've been trying for many hours to solve this problem but didn't manage to puzzle it out, any help is appreciated.</p>