Home > Backend Development > PHP Tutorial > 这个正则如何写?

这个正则如何写?

WBOY
Release: 2016-06-13 12:06:52
Original
925 people have browsed it

这个正则怎么写??
 我要取出表名。

------解决思路----------------------

<?php<br /><br />$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`))",<br />    "CREATE TABLE `order_log_2` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))",<br />    "CREATE TABLE `order_log_3` (`_id` int(11) NOT NULL AUTO_INCREMENT,,`order_info` text,`insert_time` int(11) DEFAULT NULL,PRIMARY KEY (`_id`))",<br />);<br /><br /><br />$pattern = '/CREATE TABLE `(\w+)`/i';<br /><br /><br />foreach ($array as $item) {<br /><br />    if (preg_match($pattern, $item, $match)) {<br /><br />        var_dump($match[1]);<br />    }<br /><br />}<br /><br /><br /><br /><br />?>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template