preg_match在构建器中有效,但在脚本中无效

问题描述

我正在使用创建正则表达式 https://www.phpliveregex.com/#tab-preg-match

代码如下:

$input_line = 'Sector(s) : Basic Materials Industry : Gold Full-time employees :  ';
preg_match('/Industry : (.*) Full-time employees :/',$input_line,$output_array);

在线工具中的结果符合预期,即“金”。

但是在我的代码中却没有发生:

echo preg_match('/Industry : (.*) Full-time employees :/',$arr[5],$industry_arr);

返回0。

数组$ arr看起来像这样:

Array ( [0] => [1] => [2] => [3] => [4] => [5] => Sector(s) : Basic Materials Industry : Gold Full-time employees : [6] => [7] => )

在开发人员工具中,我的数组看起来像这样,我感到困惑:

(
    [0] => 
    [1] => 
    [2] => 
    [3] => 
    [4] => 
    [5] => Sector(s) : Basic Materials 
Industry : Gold 
Full-time employees :\  
    [6] => 
    [7] => 
)

如果我回显$ arr [5],则会得到以下信息:

Sector(s) : Basic Materials Industry : Gold Full-time employees :

我想知道不间断空间是否在这里引起问题?

预先感谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)