alin19 Posted March 6, 2008 Share Posted March 6, 2008 i hava a string var like this: $x="2,5000" i need to make that $x="25000" how can i do that? Quote Link to comment Share on other sites More sharing options...
Isityou Posted March 6, 2008 Share Posted March 6, 2008 Replaces the coma with nothing. <?php str_replace(',', '', $x); <? Quote Link to comment Share on other sites More sharing options...
alin19 Posted March 6, 2008 Author Share Posted March 6, 2008 <?php $x[0]="2,700"; $x[0]= number_format($x[0], 2, '.', ''); $x[1]="1,700"; $x[1] =number_format($x[1], 2, '.', ''); $v=array_sum($x); $v= number_format($v, 2, '.', ''); echo $v; ?> and so is this: <?php $x[0]="2,700"; str_replace(',', '', $x[0]); $x[1]="1,700"; str_replace(',', '', $x[0]); $v=array_sum($x); $v= number_format($v, 2, '.', ''); echo $v; ?> this outputs me 3.00 in stead of 3.40 what i'm geting wrong? Quote Link to comment Share on other sites More sharing options...
alin19 Posted March 6, 2008 Author Share Posted March 6, 2008 solve it, sorry Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.