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

Posted by Toby Inkster on 03/08/06 10:43

David Haynes wrote:

> Iteration by indexing works and is, as I said, brute force.

Iteration by indexing works *iff* all your indexes are numeric and
sequential. Your for-loop won't work on non-sequential arrays like this:

array(
0 => '123,45',
1 => '123,45',
9 => '123,45'
);

because count() will return 3, meaning that the last element of the array,
with index 9, won't be touched. Nor will it work on:

array(
-1 => '123,45',
0 => '123,45',
1 => '123,45'
);

as your for-loop has a hard-coded start value of 0. Nor will it work on:

array(
'a' => '123,45',
'b' => '123,45',
'c' => '123,45'
);

because the keys aren't numeric. Iván's foreach-loop will work on all of
these three examples.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact

 

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

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