无论有多少朋友训练我,我对preg视而不见,所以我想知道是否有人可以提供以下帮助:
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'
我需要将此文本块转换为数组,切换为(; ) - 请注意,explode()不适用于此。
我也不介意; 必须是一行的最后一个字符,使用php :: trim()
大多数情况下,SQL必须使用',但有时也允许"
预期结果将是:
$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';