[thelist] Replacing periods with commas

FayeC ftarzwell at fayec.com
Fri Jan 4 08:45:34 CST 2008


As per my OP I would like to correct a coding issue that replaced a digit
for a comma instead of the period for a comma.
The code was written in 2002 so I guess things have changed since. I don't
have contact with the original programmer and I am not a programmer myself
so I would like to know if changing just that line will break the code.

Thanks,

FayeC

On Fri, 4 Jan 2008 14:22:45 -0000, "Kevin Timmins"
<kipper_timmins at yahoo.co.uk> wrote:
> What is it that you are actually wanting it to do if you don't mind me
> asking? And also what is the comma issue?
> 
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of ftarzwell at fayec.com
> Sent: 04 January 2008 13:49
> To: thelist at lists.evolt.org
> Subject: Re: [thelist] Replacing periods with commas
> 
> 
>>>On Jan 3, 2008 1:16 PM,  <ftarzwell at fayec.com> wrote:
>>>
>>> I have an output file that should display:
>>> 864,7 $    +8.2
>>> Instead it's showing:
>>> 86,.7 $    +,.2
>>>
>>> The code that does the replacement of the period for a comma is as
> follows:
>>> $change = substr_replace($change, ",", strlen($change) - 3, 1);
>>>
>>> Should the code be:
>>> $change = substr_replace($change, ",", strlen($change) - 2, 1);
>>>
>>> in order to fix the comma issue?
>>
>>Actually, I'd use strtr (http://php.net/strtr) instead:
>>
>>$change = strtr($change, ',' , '.');
>>
>>That way you never have to worry about how many digits are in the number.
>>
>>Brady
> 
> Hi Brady,
> 
> Thank you for the help. Will using this alternate way mess up the rest of
> the code?
> Also, based on the php.net page it should be $change, "string $from",
> "string $to".
> In this case should I write ($change, '.', ',') ??
> 
> Thanks,
>  FayeC
> 
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
> 
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !




More information about the thelist mailing list