You are here: Re: problems changing point for coma... « PHP Programming Language « IT news, forums, messages
Re: problems changing point for coma...

Posted by Ivαn Sαnchez Ortega on 03/07/06 23:46

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David Haynes wrote:

> A brute force method:
> for( $i = 0; $i < count($array_with_numbers); $i++) {
> str_replace(',', '.', $array_with_numbers[$i];
> }

Never use a for(;;) loop to iterate over an array: you are creating
error-prone code.

Either use foreach() with references:
<?php
foreach($array_with_numbers as &number)
str_replace(',', '.', $number);
?>

Or use array_map to automatically transverse the array applying a function
to every element, or (even better) use a recursive function.

Or, you can RTFM. http://php.net/str_replace , the part that says:

"If subject is an array, then the search and replace is performed with every
entry of subject, and the return value is an array as well."


So, please go RTFM.

- --
- ----------------------------------
IvΓ‘n SΓ‘nchez Ortega -i-punto-sanchez--arroba-mirame-punto-net

"All truth passes through three stages. First, it is ridiculed. Second, it
is violently opposed. Third, it is accepted as being self-evident."
- Arthur Schopenhauer (1788-1860)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFEDf863jcQ2mg3Pc8RAn5MAJ9eJ+FYy7Zh6Dmr5O1UfkIIGdnLTwCbBmKZ
VD+NBSUgRGFj9HBbG206CSI=
=VWqE
-----END PGP SIGNATURE-----

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация