PHP Validating decimal numbers and converting to US currency format
<p>I am working currently with PHP validation of decimal values. The function works well in determining decimals/integers from letters but my goal is to format the decimal/integer values into proper currency values such as <code>$0.00</code>. </p>

<p>How can I format the input value into currency format with the dollar sign such as <code>$0.00</code>?</p>

<p><a href="http://webprolearner.ueuo.com/dropdown-menu/test1.php" rel="nofollow">EXAMPLE</a></p>

<pre><code>&lt;?
if (isset($_POST['price'])){
    $price = $_POST['price'];
    $priceString = empty($price['price'])?null:trim($price['price']);
            if(!empty($priceString)) { 
         if  (preg_match('/^[+\-]?\d+(\.\d+)?$/', $price)){
             echo ('&lt;div id="price_input"&gt;&lt;span id="resultval"&gt;'.$price.'&lt;/span&gt;&lt;/div&gt;');
                }
             else {
             echo ('&lt;div id="price_input"&gt;&lt;span id="resultval"&gt;Please input a valid decimal number.&lt;/span&gt;&lt;/div&gt;');
                  }
    }
    else {
        echo '';
         }              
}
?&gt;
</code></pre>
