mysql - how to loop data from database seperated with coma in php -
i have variable called $to. want variable contain data database separated coma below
$to='belong@gmail.com, getthis@gmail.com'; if there 1 email on database there no coma, if there more 1 email coma on last email disappear.
you can use explode convert array. can traverse array
<?php $to='belong@gmail.com, getthis@gmail.com'; $to_array = explode(",", $to); foreach ($to_array $key => $value) { echo $value; } if want opposite can use implode
$to_array = array('belong@gmail.com', 'getthis@gmail.com'); $to = implode(",",$to_array); echo $to;
Comments
Post a Comment