title: Tweaking of a preg_replace string to hide the decimals of a price
body: <p>I have this code:</p>
  
  <pre><code>$string = '/([\d,]+)\.(\d+)(.*)$/';
  
  $condition = preg_replace($string, '$2', $price);
  
  if ($condition == 00) {
  
  $show = preg_replace($string, '$1$3', $price);
  
  } else {
  
  $show = preg_replace($string, '$1.$2$3', $price);
  
  }
  </code></pre>
  
  <p>So, if I have the price in this format: <strong>100.00€</strong> after the code is executed, the price is shown like this: <strong>100€</strong></p>
  
  <p>But if I have the price in this format: <strong>$100.00</strong> after the code is executed, the price is still shown like this: <strong>$100.00</strong> i.e. the <strong>00</strong> is not trimmed (the second <strong>$show</strong> after the <strong>else</strong> statement is loaded).</p>
  
  <p>The <strong>$price</strong> is generated with the currency symbol all together, so it's not just a pure number.</p>
  
  <p>Any suggestions how can I make this happen, regardless the currency postion (left or right)?</p>
  
  <p>Thanks.</p>
  
  <p><strong>P.S.</strong> It doesn't need to be this code, you can suggest another one, as long as it makes the 00 decimals to dissapear if equal to zero, regardles the position of the currecy symbol.</p>