|
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
Navigation:
[Reply to this message]
|