这样的递归怎么做?!
<br /> select a,<br /> (select b from c where ...) as d,<br /> e<br /> from f,(select j from h where ...) as i<br /> where ....<br />
<br /> select count(*)<br /> from f,(select j from h where ...) as i<br /> where ....<br />
$s = <<< TXT<br /> select a,<br /> (select b from c where ...) as d,<br /> e<br /> from f,(select j from h where ...) as i<br /> where ....<br /> TXT;
$ar = preg_split('/(\(?\bselect\b
------解决方案--------------------
\bfrom\b)/i', $s, -1, PREG_SPLIT_NO_EMPTY
------解决方案--------------------
PREG_SPLIT_DELIM_CAPTURE);
$n = 0;
$st = array();
for($i=0; $i$t = strtolower($ar[$i]);
if($t == 'select'
------解决方案--------------------
$t == '(select') {
$st[] = $i;
}
if($t == 'from') {
if(count($st) == 1) break;
array_pop($st);
}
}
for($i--; $i>$st[0]+1; $i--) unset($ar[$i]);
$ar[$st[0]+1] = " count(*)\n";
echo join('', $ar);