I need to add append data to a string if a certain variable is true, if not, I don’t need to append anything. Currently I’m doing:
$string = (condition()) ? 'something'.$string.'something' : $string;
Is there a way to skip adding the false option in a ternary operator? It seems wasteful to say $string = $string if the condition is false.
You can’t skip it. You could re-write as a one line
ifcondition though: