Jump to content

Errors Using Preg_split to separate by commas


rookwood

Recommended Posts

I am trying to split some strings up by commas with preg_split but I keep on getting the error: "No ending delimiter ',' found"

 

Here is my Code:

$links = preg_split(',', $links);
$titles = preg_split(',', $titles);
$images = preg_split(',', $images);

 

Thanks,

Alex

Thanks it works now

 

You see now that explode() is the more appropriate function, but to answer you question:  preg functions need a regular expression which consists of some starting and ending delimiters.  They can be most anything but common ones that you will see are / # ~.

 

$links = preg_split('/,/', $links);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.