I have an array, and I'm trying to concatenate some values โโof this array. Currently, $allit looks like this: "AmazonSonySmashwordsBN" (see code below)
How do I look like this: Amazon, Sony, Smashwords, BN
I understand how to concatenate. My problem is that I don't want a comma if one of the lines of $ bookcategory is empty.
$book = array("18"=>'BN', "19"=>'Amazon', "20"=>'Sony', "21"=>'Kobo', "22"=>'Smashwords', "23"=>'Apple', "24"=>'Android');
$bookcategory1 = $book[$catagory1];
$bookcategory2 = $book[$catagory2];
$bookcategory3 = $book[$catagory3];
$bookcategory4 = $book[$catagory4];
$all = $bookcategory1 . $bookcategory2 . $bookcategory3 . $bookcategory4;
echo $all;
Thanks!
source
share