使用preg_split而不是split [英] use preg_split instead of split

查看:77
本文介绍了使用preg_split而不是split的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用FPDF v.1.53.现在,我切换到了较新的PHP版本.现在不推荐使用功能split.我在第108行的fpdf_eps.php中包含以下代码:

I'm using FPDF v. 1.53. Now I switched to a newer PHP version. The function split is now deprecated. I had on line 108 the following code in fpdf_eps.php:

$lines = split ("\r\n|[\r\n]", $data);

我想将其更改为preg_split

I wanted to change it to preg_split

$lines = preg_split ("\r\n|[\r\n]", $data);

,但是脚本似乎有错误,并且我只会得到未找到的消息页面(如果脚本有错误,我总是会得到此消息).怎么了?正则表达式?

but than the script seems to have an error and I only get the message page not found (I always get this if a script has an error). What is wrong? The regexp?

推荐答案

将正则表达式与preg一起使用时,应将正则表达式包含在斜杠内.您的正则表达式应如下所示:

When using regular expressions with preg, you should contain your regex inside slashes. Your regex should look like this:

$lines = preg_split ("/\r\n|[\r\n]/", $data)
                      ^           ^

这篇关于使用preg_split而不是split的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆