In my database I have a "willingness" field with a value like: sports,pub,drink,drive,smile etc.
When do this in my template:
<? echo '<p>'.$willingness.'</p>'; ?>
I get a string: sports,pub,drink,drive,smile How can I break this into words like: sports, pub, drink, drive, smile?
Thank you!
$arrayWillingness = explode(",", $willingness);
echo $arrayWillingness[0]; //sports
echo $arrayWillingness[1]; //pub
echo $arrayWillingness[2]; //drink
echo $arrayWillingness[3]; //drive
echo $arrayWillingness[4]; //smile
If you're using it in a loop:
$arrayWillingness = explode(",", $willingness);
foreach ($arrayWillingness as $value) {
echo $value;
}