0

I am trying to write an echo to echo a variable and a rtrim function but I can't seem to get the syntax right. Can anyone help with how to write this line correctly?

if ($str == ""){echo "$tech_name";}
    else echo "$tech_name" rtrim($str,",");
  • You can also create a one-liner: `echo (empty($str) ? $tech_name : $tech_name.rtrim($str,',');` or `echo $tech_name.(empty($str) ? '' : rtrim($str,','));`. You don't need the `$tech_name` inside quotes – ctwheels Jun 22 '17 at 19:18

1 Answers1

0

Concatenate the rtrim?

else {
    echo "$tech_name" . rtrim($str,",");
}
Paul T.
  • 4,703
  • 11
  • 25
  • 29