You are here: Re: Tricky array question « PHP Programming Language « IT news, forums, messages
Re: Tricky array question

Posted by jamesgoode on 11/07/07 20:09

On Nov 7, 8:02 pm, Good Man <he...@letsgo.com> wrote:
> jamesgoode <ja...@jgoode.co.uk> wrote in news:1194465491.529347.23280
> @d55g2000hsg.googlegroups.com:
>
>
>
> > Hi,
>
> > I've got a complicated problem to solve. Say I have an indexed array
> > $array, with contents as follows:
>
> > 'name' => 'James'
> > 'favefood' => 'Spagbol'
> > 'os' => 'Debian GNU/Linux'
>
> > And say I want to create a list, that prints the name of each item,
> > and then its contents, like this:
>
> > name: James
> > favefood: Spagbol
> > os: Debian GNU/Linux
>
> > The only problem, I don't what the items in the array are called, so I
> > can't do this:
>
> > os: <?=$array['os']?>
>
> > Any ideas? It's got me stumped.
>
> > Thanks in advance,
>
> foreach($array as $key=>$value) {
> echo "$key: $value <br>";
>
> }
>
> Also, as mentioned elsewhere, future-proof your code and lose the short
> tags... no more <?= $myVar ?>, and only <?php echo $myVar; ?>

Hi Good Man,

Thanks for your fast response, now I can continue with my project :-).

Regards,

--James

 

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

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