Jump to content

replacing a simbol from a string var


alin19

Recommended Posts

<?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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.