You are here: Re: [PHP] Strange key behaviour « PHP « IT news, forums, messages
Re: [PHP] Strange key behaviour

Posted by Guillermo Rauch on 02/08/05 01:26

On Tue, 08 Feb 2005 00:19:20 +0100, Johannes Reichardt
<mailbox@gramba.net> wrote:
> Hey there!
Hi Johannes
>
> i have a routine like this:
>
> $myarray['1'] = 'aösldfjkasöldkjf';
>
> foreach($myarray as $key => $value) {
> echo $key{0}; // outputs nothing
> echo substr($key,0); // outputs 1 like intended
> }
>
> Any ideas why this is like that? I am using
$key is just a string, not an array.

You should call it as $key.

foreach($myarray as $key => $value) {
echo $key // outputs 1
}

Good luck,
-Guillermo
>
> php 4.3.11-dev
>
> - Johannes
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

 

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

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