Convert database field divided into commas in separate variables with PHP

2

How can I convert database results that are within a field divided by commas, into separate variables independently of the number of results contained in the field.

Example:

I have:

$row['campo'] = 333,444,555,6666

I need:

$var1='333'; 
$var2='444'; 

.
.
    
asked by anonymous 21.03.2016 / 15:39

1 answer

7

Using the function explode () ;

Ex:

$row['campo'] = 333,444,555,6666

$aux = explode(",", $row['campo']);

foreach($aux as $v){
  echo $v;
}
    
21.03.2016 / 15:46