0

I have the following information in a MySQL column:

**rubros**
Internet
Internet, Diseño
Arquitectura, Construcción
Textiles

And I need to get an array of individual ítems in that list, something like this:

array('Internet','Diseño','Arquitectura','Construcción','Textiles');

Is there an easy way to do this with PHP?

Thanks.

Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119
user906379
  • 107
  • 9
  • 1
    You should normalize your database design. – jeroen Apr 20 '15 at 16:15
  • 2
    select your field, then while fetching do an `explode()` to split into separate values... then after you're done that, rebuild your db with a properly normalized design. once you've done that, your question becomes irrelevant. – Marc B Apr 20 '15 at 16:16
  • This isn't a database I set up or am allowed to modify. Is there a way to do this without changing it's design? – user906379 Apr 20 '15 at 16:20
  • Take a look at this: http://stackoverflow.com/questions/19073500/sql-split-comma-separated-row. After you have your column split, then SELECT distinct values from it, – Mark Leiber Apr 20 '15 at 16:25

1 Answers1

0

As Marc B suggest, assuming the DB query result is in $values, something like this would do the job:

$result = array();
foreach($values as $value) $result = array_merge($result, explode(", ", $value));
maalls
  • 749
  • 8
  • 20