duanjurong1347 2013-03-03 21:05
浏览 33
已采纳

在免费服务器上禁用preg_split? [关闭]

I'm developing a PHP script which use the preg_split function. In my computer, using EasyPhp everything works but when I put the files on-line on a free space the function preg_split seems not to work (I have no error message on the screen but the string is not splitted). Is it possibile that this function have been disabled? The version of PHP is PHP 5.2.17 - Optimized for AlterVista so the function should works...is there any alternatives?

The script is made to transform a *.pdf file (saved as a *.txt file) which contains a list of value with the same structure in every page. The following is an example.

Page 1: This is the today harvest. Day: 01/12/2012 Apple 12 Bananas 14 Kiwi 2

Page 2: This is the today harvest. Day: 02/12/2012 Apple 19 Bananas 36 Kiwi 0

Page 3: This is the today harvest. Day: 03/12/2012 Apple 1 Bananas 1 Kiwi 73

The original document contains almost 50 different fruits and have a more complex structure, this is just a simple example of the achievement and the reasons why I am using Regex. I use the following code to create an array named $document_pg where every element is a page of the original document.

$document_pg = preg_split("(This is the today harvest.)", $document);

then I use some a couple of preg_match function to extract the numbers that are wrote on the left of the fruit name. These values will be saved in a database.

  • 写回答

2条回答 默认 最新

  • douding7189 2013-03-03 21:17
    关注

    It may be that PHP on your server has been compiled --without-pcre-regex (PCRE only has been mandatory since 5.3.0), so your only option may be to use the deprecated ereg regex functions. Does the following work?

    $document_pg = split('(This is the today harvest\.)', $document);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog