I m blind at preg no matter how many friends trained me, so i wonder if someone could help with the following:
SELECT * from tab where a='this is SQL1';
SELECT * FROM tab WHERE a='this is SQL2;
this is also inside SQL2';
SELECT * FROM tab where a="this is SQL3;
this is also inside SQL3";
SELECT * from tab where a='this is SQL4;
this is '' also inside SQL4'
I need to convert this text block into an array, cutting at (;) -- please note that explode() will not work for this one.
I also do not mind that the ; have to be the last char at end of a line by using php::trim()
Most cases SQL have to use ', but sometimes also allowed "
The expected result will be:
$arr[0] = 'SELECT * from tab where a=\'this is SQL1\'';
$arr[1] = 'SELECT * FROM tab WHERE a=\'this is SQL2;
this is also inside SQL2\'';
$arr[2] = 'SELECT * FROM tab WHERE a="this is SQL3;
this is also inside SQL3"';
$arr[3] = 'SELECT * from tab where a=\'this is SQL4;
this is \'\' also inside SQL4';