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? Link to comment https://forums.phpfreaks.com/topic/94656-replacing-a-simbol-from-a-string-var/ 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); <? Link to comment https://forums.phpfreaks.com/topic/94656-replacing-a-simbol-from-a-string-var/#findComment-484666 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? Link to comment https://forums.phpfreaks.com/topic/94656-replacing-a-simbol-from-a-string-var/#findComment-484678 Share on other sites More sharing options...
alin19 Posted March 6, 2008 Author Share Posted March 6, 2008 solve it, sorry Link to comment https://forums.phpfreaks.com/topic/94656-replacing-a-simbol-from-a-string-var/#findComment-484682 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.