Reply to Re: setting values in associative array to 0

Your name:

Reply:


Posted by Chuck Anderson on 06/06/05 22:46

pauld wrote:

>tried that but doesnt seemt to clear the array values.
>
>IIRC there is soemthing that gives an array of keys
>I could then do a $arrayofkeys as $k
>{$array[$k]=0 }
>
>cant find the function though
>
>
>
Not sure why the tested versions work, but this is from the manual:

"Note: Also note that foreach operates on a copy of the specified array
and not the array itself. Therefore, the array pointer is not modified
as with the each() construct, and changes to the array element returned
are not reflected in the original array. However, the internal pointer
of the original array is advanced with the processing of the array.
Assuming the foreach loop runs to completion, the array's internal
pointer will be at the end of the array."

And a possible solution:

"As of PHP 5, you can easily modify array's elements by preceding $value
with &. This will assign reference instead of copying the value. "


--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************

[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

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