Page 1 of 1

php Parsing From Stored Mysql comma seprated Data

Posted: Tue Dec 15, 2009 6:03 am
by adpkumar
php Parsing From Stored Mysql comma seprated Data


like

id subject
1 science,maths
2 maths,english,science
3 history,maths


i want to display
science
maths
english
history

can u help me

Re: php Parsing From Stored Mysql comma seprated Data

Posted: Tue Dec 15, 2009 1:22 pm
by Christopher
Use explode() see the manual.

Re: php Parsing From Stored Mysql comma seprated Data

Posted: Tue Dec 15, 2009 1:39 pm
by AbraCadaver
And array_unique():

Code: Select all

$result = array();
foreach ($row as $val) {
    $result = array_merge($result, explode(',', $val));
}
$result = array_unique($result);