Need a fast and easy way to generate an array of the different values for a SET or ENUM data type in MySQL? This example assumes you've already retrieved the value of the "Type" column. For information on how to do this, read this MySQL article on the SET datatype.

In PHP:

// input format: set('item','item2','item3')
// strip set() and quotes
$strType = preg_replace("/^(set|enum)(|[']+|)$/i", "", $strType);

// assign to the array
$arr = split(',', $strType);

In C#:

// imports
using System.Text.RegularExpressions;

// input format: set('item','item2','item3')
// strip set() and quotes
strType = RegEx.Replace(strType, "^(set|enum)(|[']+|)$", 
                String.Empty, RegExOptions.IgnoreCase);

// assign to the array
arrTypes = strType.Split(',');

And there you go! Enjoy.