$s = '*** $floor_check[$value[$floor[abc]]]***';
在最里层的[abc]加上引号
function addQuote($str){
$str = preg_replace("//[([^/[/]]+)/]/","['//1']",$str);
return $str;
}
$s = preg_replace('//$/w+/[([^/[/]]+|(?R))*/]/e',"' /''.addQuote('//0').'/' '",$s);
结果 string(46) "*** '$floor_check[$value[$floor['abc']]]' ***"
搜了很久 这篇日志对我很有用 http://www.uini.net/2010/05/the-recursive-regular-php.html