我要取出表名。
这个数组里些是创建表的sql语句,然后我想要获取到表名,帮写个正则 - -
<?php$array = array("CREATE TABLE `order_log_1` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))", "CREATE TABLE `order_log_2` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))", "CREATE TABLE `order_log_3` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))",);$pattern = '/CREATE TABLE `(\w+)`/i';foreach ($array as $item) { if (preg_match($pattern, $item, $match)) { var_dump($match[1]); }}?>