Explode variable with commas to separate lines

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

$rows1['gphours']

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.
damianb123Asked:
Who is Participating?
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

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

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

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.
0
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 :-)
0
Dave BaldwinFixer of ProblemsCommented:
I would choose the str_replace() method also.
0
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
PHP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.