Convert comma-divided database field into separate variables with PHP

Asked

Viewed 31 times

2

How can I convert database results that are within a comma-divided field into separate variables regardless of the number of results contained in the field.

Example:

Have:

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

Precise:

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

.
.

1 answer

7


Using the function explode();

Ex:

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

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

foreach($aux as $v){
  echo $v;
}
  • Thank you, perfect Fernando.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.