How to add currency strings (non-standardized input) together in PHP?
<p>I have a form in which people will be entering dollar values.</p>

<p>Possible inputs:<br>
$999,999,999.99<br>
999,999,999.99<br>
999999999<br>
99,999<br>
$99,999<br></p>

<p>The user can enter a dollar value however they wish. I want to read the inputs as doubles so I can total them.</p>

<p>I tried just typecasting the strings to doubles but that didn't work. Total just equals 50 when it is output:</p>

<pre><code>$string1 = "$50,000";
$string2 = "$50000";
$string3 = "50,000";
$total = (double)$string1 + (double)$string2 + (double)$string3;
echo $total;
</code></pre>
