Reply to Re: Checkbox array passes to script fine but doesn't mail right

Your name:

Reply:


Posted by Rik on 02/01/07 01:28

JackM <notme@earthlink.net> wrote:
> Rik wrote:
>> foreach($_POST as $key =3D> value){
>> $message =3D $key . ': '.((is_array($value)? implode(',',$value)=
: =

>> $value);
>> }
>
> So if I'm reading that correctly, that's another way of saying:
>
> foreach($_POST as $key =3D> $value){
> if(is_array($value)){
> $message =3D $message . "$key: ".implode( ', ', $value)."\n\n";
> } else {
> $message =3D $message . "$key: $value\n\n";
> }
> }
>
> Close interpretation, maybe? At least the code works. ;-)

Yup, except my code obviously didn't have the "\n\n" :-)
It's called the ternary operator, and saves a lot of lines/if-else block=
s =

for simple conditionals.

Also, '.=3D', will save some typing here:
$message .=3D "$key: ".implode( ', ', $value)."\n\n";
-- =

Rik Wasmus

[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

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