I have a string... ENUM('0','1')
and I want to get an array... array('ENUM', array(0, 1));
and I want to do it with preg_replace instead of using multiple complicated explode statements like so...
$showColumns = 'SHOW COLUMNS FROM table';
if (strpos($show[$k][1], '(')!==FALSE) {
$showType = explode("(", $show[$k][1]);//PREG_SPLIT IS BETTER
}
$elementType = strtoupper($showType[0]);
$type = $this->FIELD_TYPE[$elementType];
$vals = explode(")", $showType[1]);
if (is_integer($vals[0])) {
$values = $vals[0];
}elseif (strpos($vals[0], ',')!==FALSE) {
$vs = explode(',', $vals[0]);
$vs = array_map('str_replace', $vs, array('\'', '', $vs[0]));
$values=array();
foreach ($vs as $v) {
$values[] = $v;
}
}
$values = $vals[0];
print $values; print '<br /><br />';