Explode variable with commas to separate lines

    I have a value which is pulled from a MySql query which looks like this:


This value contains text like this:

Monday 9-5, Tuesday 10-4, Wednesday 9-4

What i need to do is perform an explode or implode and add a <br>, so the output looks like:

Monday 9-5
Tuesday 10-4
Wednesday 9-4

I can't think how to get it going....

Any help much appreciated.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Marco GasiFreelancerCommented:
if you need to end up with a string you can jut do what you said:

$arr = explode(',', $rows1['gphours']);
$end_string = implode('<br>', $arr);

Open in new window

How about a string replace http://php.net/str_replace  replacing the , with a <br>

$hours= str_replace(",", "<br>", $rows1['gphours']);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
damianb123Author Commented:
Perfect, did the job nicely.... Thanks - I thought I was nearly there, it's been a long day, so thanks for your quick response.
Marco GasiFreelancerCommented:
Thanks for points but I was sure you would choose rjohnsonjr solutions: simpler, quicker and definitely more intelligent. My solution is intricate without reason. Please, consider to request attention to the moderator using the link immediately below the question box and award points to rjohnsonjr: he deserves points and future members could find my bad solution instead of the good one :-)
Dave BaldwinFixer of ProblemsCommented:
I would choose the str_replace() method also.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.