Reply to Re: problems changing point for coma...

Your name:

Reply:


Posted by David Haynes on 03/08/06 00:23

Iván Sánchez Ortega wrote:
> -----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.

I suspect you are having a bad day.
Iteration by indexing works and is, as I said, brute force.

-david-

[Back to original 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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация