<?php $var1 = "abc";$var2 = "";$var3 = "def"; echo implode(', ', array_filter([$var1, $var2, $var3]));
Standard input is empty
abc, def
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!