79724325

Date: 2025-08-03 21:32:49
Score: 1.5
Natty:
Report link

The ternary operator may be used for assigning directly a value to a key of an associative array, but it is not possible to generate the key name itself by this way !

For such a scenario, it is better to append (or not) a key=>value as a whole, to the array, if a condition is true. Of course, that condition can be evaluated with a ternary operator.

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: user3403511