Awesome! Thank you so much, Micha!
--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Michael Fesser" <netizen@gmx.de> wrote in message
news:7s1f04diu6r7j3rko432b27k6cfvpdn127@4ax.com...
> .oO(Murray *ACE*)
>
>>Like this -
>>
>><?php echo (fieldvalue) == 'Y'?'Yes':(fieldvalue)
== 'M'?'Maybe':'No'; ?>
>
> Without parentheses this won't work as expected, because
in PHP the
> ternary operator is left-associative (in many other
languages it is
> right-associative, so it would work there). The result
will always
> be "Maybe" or "No", but never "Yes", because the result
of the first
> ternary operator is seen as an operand of the second
operator, which
> will return the result string.
>
> In a more formal way an expression like above without
any parentheses:
>
> R = A ? B : C ? D : E
>
> in PHP will be evaluated as
>
> R = (A ? B : C) ? D : E
>
> instead of the intended
>
> R = A ? B : (C ? D : E)
>
> So you should either wrap the second operator in
parentheses or negate
> the first condition and change the operands of the first
operator like
> this:
>
> R = !A ? C ? D : E : B
>
> This kind of nesting works. The same in a slightly more
readable form:
>
> R = !A
> ? C ? D : E
> : B
>
> or even like this, if the expressions are a bit longer:
>
> R = !A
> ? C
> ? D
> : E
> : B
>
> Applied to the original expression this will work:
>
> $result = $fieldvalue != 'Y'
> ? $fieldvalue == 'M'
> ? 'Maybe'
> : 'No'
> : 'Yes';
>
> Micha