A
A
Artem Golomazov2016-02-05 17:04:55
PHP
Artem Golomazov, 2016-02-05 17:04:55

How to create a regular expression to display words separated by commas?

Good afternoon!
There is a string of the form: 110, 50, 42, 69
Purpose: to extract what is between the commas, for subsequent conversion to the form

<div id="bus_tag">110</div><div id="bus_tag">50</div>
etc.
As far as I understand, you need to look in the direction of preg_match, but I still could not figure out regular expressions.
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
Justique, 2016-02-05
@Golomazov20

$str = explode(', ', '110, 50, 42, 69');
foreach($str as $val){
echo '<div id="bus_tag">' . $val . '</div>';
}

S
Stalker_RED, 2016-02-05
@Stalker_RED

explode() won't work?

A
Andrey, 2016-02-05
@VladimirAndreev

$data = explode(',', '110, 50, 42, 69');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question