PHP money_format: issues with values 0.00/0.50/.50
<p>I am currently validating US Currency along with a decimal number format. I am using the function <code>money_format</code>but the issues is that certain values is returning an error.</p>

<p>How can i have the function work when the input value is <code>0.00</code> or <code>0.50</code>? <a href="http://webprolearner.ueuo.com/dropdown-menu/test1.php" rel="nofollow">Example</a></p>

<p><strong>PHP</strong></p>

<pre><code>if (isset($_POST['price'])){
    $price = $_POST['price'];
    $priceString = empty($price['price'])?null:trim($price['price']);
        if(!empty($priceString)) { 
            $price = str_replace("$", "", $price); 
                if  (preg_match('/^[+\-]?\d+(\.\d+)?$/', $price)){
                 echo ('&lt;div id="price"&gt;&lt;span id="resultval"&gt;&lt;h2&gt;Price:&lt;/h2&gt;'.money_format('%n', $price).'&lt;/span&gt;&lt;/div&gt;');
                           }
                     else {
             echo ('&lt;div id="price"&gt;&lt;span id="resultval"&gt;&lt;h2&gt;Price:&lt;/h2&gt;&lt;div class="errorMessage"&gt;Enter a valid number in US currency format.&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;'); 
                           }
}
            else {
            echo '';
            }
}
</code></pre>
