Pergunta

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.

Foi útil?

Solução

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);

Outras dicas

Although it's fairly difficult to say without checking with the hosting provider in question - odds are that the displaying of warnings has been turned off as well by this provider. When this function is disabled it generates a warning level notice which you probably aren't seeing.

To answer your question - it is entirely possible via php ini file to disable functions like this . See here disable_functions

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top