Reply to Re: Tricky array question

Your name:

Reply:


Posted by lawrence k on 11/08/07 04:13

On Nov 7, 2:58 pm, jamesgoode <ja...@jgoode.co.uk> wrote:
> 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.

I often do this:

while (list($key, $val) = each($array)) {
echo "os: $key ";
}


If I have an array just input by a form, and I need to addslashes
before sending it to a database, this is quite useful:

while (list($key, $val) = each($formInputs)) {
$formInputs[$key] = addslashes($val);
}

[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

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