Why ternary operator doesn't work with assignment by reference?
$obj = new stdClass(); // Object to add
$result = true; // Op result
$success = array(); // Destination array for success
$errors = array(); // Destination array for errors
// Working
$target = &$success;
if(!$result) $target = &errors;
array_push($target, $obj);
// Not working
$target = $result ? &$success : &$errors;
array_push($target, $obj);
See Question&Answers more detail:os