Copy link to clipboard
Copied
I would like to print a comma-separated entry into separated entries:
Like when I put like <?php echo $row_rsContent['artists']; ?> I get: "Picasso,Chagall,Matisse" but I want it like "Picasso<br>Chagall<br>Matisse".
And also I want to link "Picasso" to another website.
Thanks for any furthre help.
Pass your variable to explode() to turn it into an array. Then do what you want with each element.
$artists = explode(',', $row_rsContent['artists']);
echo '<a href="link">' . $artists[0] . </a><br>';
echo $artists[1]. '<br>' . $artists[2] . '<br>';
Copy link to clipboard
Copied
Pass your variable to explode() to turn it into an array. Then do what you want with each element.
$artists = explode(',', $row_rsContent['artists']);
echo '<a href="link">' . $artists[0] . </a><br>';
echo $artists[1]. '<br>' . $artists[2] . '<br>';
Copy link to clipboard
Copied
Thanks a lot again.
I put like that (see below) .. because I have maybe even 10 or more "artists" I wonder if there is a possibility to do this in a kind of "repeated region"?
<?php $artists = explode(',', $row_rsContent['nameArtist']); ?>
<a href="artist2.php?cat=<?php echo $row_rsContent['casco_cat_id']; ?>&artist=<?php echo $artists[0]; ?>"><?php echo $artists[0]; ?></a><br>
<a href="artist2.php?cat=<?php echo $row_rsContent['casco_cat_id']; ?>&artist=<?php echo $artists[1]; ?>"><?php echo $artists[1]; ?></a><br>
<a href="artist2.php?cat=<?php echo $row_rsContent['casco_cat_id']; ?>&artist=<?php echo $artists[2]; ?>"><?php echo $artists[2]; ?></a><br>
<a href="artist2.php?cat=<?php echo $row_rsContent['casco_cat_id']; ?>&artist=<?php echo $artists[3]; ?>"><?php echo $artists[3]; ?></a><br>
Copy link to clipboard
Copied
Oh, you want them all in links? That makes it a lot easier. Your original message said just the first one would be in a link. The following should do it:
<?php $artists = explode(',', $row_rsContent['nameArtist']);
foreach($artists as $artist) { ?>
<a href="artist2.php?cat=<?php echo $row_rsContent['casco_cat_id']; ?>&artist=<?php echo $artist; ?>"><?php echo $artist; ?></a><br>
<?php } ?>
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more