I want to split by comma inside braces except another braces inside braces
$q1 ="CREATE TABLE notes(id INTEGER,code DECIMAL (4,2),PRIMARY KEY (id))";
$q2 ="CREATE TABLE notes(id INTEGER,code TEXT)";
$r = preg_split('/\([^()]*\)(*SKIP)(*F)|[()]|,/', $q1);//$q1 splitted but $q2 no
print_r($r);
The final result should be:
for $q1 :
array(
0 => id INTEGER
1 => code DECIMAL (4,2)
2 => PRIMARY KEY (id)
);
for $q2 :
array(
0 => id INTEGER
1 => code TEXT
);