Here you go
$target = ($result ? &$success : &$errors);
Also your example has two typos
change
http://php.net/manual/en/language.operators.comparison.php
Note. Note that the ternary operator is an expression and that it does not evaluate the variable, but the result of the expression. It is important to know if you want to return the variable by reference. The operator returns $ var == 42? $ a: $ b; therefore, the return-by-reference function will not work and a warning will be issued in later versions of PHP.
idk if this worked before but this is no longer there. if you do not want to use the if statement, try the following:
$result ? $target = &$success : $target = &$errors;
or on leased lines ...
$result ? $target = &$success : $target = &$errors;
source share