spilt replace to preg_split problem

[php] $getvalue = preg_split(",",$_POST[‘CUSTOM’]); [/php]

The site stopped running I inherited this site) and I traced the errors and tried to change as per the findings,

I only replace the code split to preg_split and get the following error.

Therea re many other places that I have to change either split or eregi in the programs. ;D

[25-May-2012 07:02:12 UTC] PHP Warning: preg_split() [function.preg-split]: No ending delimiter ‘,’ found in /home/savvydea/public_html/demo/system/modules/gateway/paypal/ReviewOrder.php on line 381[php][/php]

Have been programming for many years but not in PHP. I have been reading the manuals.

Hi,

The ‘pattern’ you use for your regex (regular expression) is not correct.
There is a lot of documentation about regexes but in short:
The pattern part needs a ‘limiter’ character. Usually people use ‘/’, but the engine takes the first character it finds apparently. In your case that’s a ‘,’.

Your problem would be solved if you put ‘/,/’ instead of ‘,’.

Rests me one question. preg_split is powerful, it can split on lots of different things in one line. for just a split on one character you may want to consider ‘explode()’.

the syntax for ‘explode()’ is:
[php]
$String = ‘een,twee,drie,vier,vijf’;
$splitCharacter = ‘,’;
$arrayOfStrings = explode( $splitCharacter, $string );
[/php]

Hope this helps,
O.

PS. if you want to know more about PHP regexes: http://webcheatsheet.com/php/regular_expressions.php

HI Thanks for that.
;DIt has led to other problems. I will post these in another post.

Sponsor our Newsletter | Privacy Policy | Terms of Service