Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php preg_match_all在尝试获取包括空格在内的所有字符时不起作用_Php_Mysql_Preg Match_Preg Match All - Fatal编程技术网

Php preg_match_all在尝试获取包括空格在内的所有字符时不起作用

Php preg_match_all在尝试获取包括空格在内的所有字符时不起作用,php,mysql,preg-match,preg-match-all,Php,Mysql,Preg Match,Preg Match All,以下是我的功能: function grabstuff() { foreach (glob("../folder/*.php") as $fn) { $file = file_get_contents($fn); preg_match_all("#\{\('(\w+)'\)}#", $file, $matches); foreach ($matches[1] as $match) {

以下是我的功能:

function grabstuff()
{
    foreach (glob("../folder/*.php") as $fn) 
    {
        $file = file_get_contents($fn);

        preg_match_all("#\{\('(\w+)'\)}#", $file, $matches);   

        foreach ($matches[1] as $match) 
        {

            $query = ("ALTER TABLE xxxxx ADD COLUMN `$match` LONGTEXT AFTER xxxxx;");

            $result = mysql_query($query) or die("Err: ".mysql_error());

        }
    }
}
以下是它在页面上查找的内容:

<?/*{('test test')}*/?>
它忽略了这个有空格的实例。它在testtest和test_测试中运行良好。没有得到任何php错误或mysql错误。我需要使用\w+\S还是\w+\w?我两个都试过了,甚至。。。但它仍然不起作用。如何让我的上述函数识别{}中的任何字符,无论它们是普通abc字符还是空白。我相信这很简单。我在谷歌和这里做过研究,但没有找到解决方案。如果有帮助的话,任何给定页面上都会有多个{}实例。我已经使用这个函数有一段时间了,但是我想添加包含空格的功能。谢谢

'(\w+)'
\w是所有字母数字字符和下划线-不包括空格。只需使用一个字符集:

'([\w\s]+)'