preg_split instead of split

Since split is depracated in 5.3 and removed in 6, I am doing a quick check on some scripts I have, in which the developer is long gone and won’t be doing any updates.

Luckily, there are only a few instances of “split” found and I planned on replacing them with preg_split -but it is not working. The scripts work with split (since it is just deprecated in 5.3) but won’t work as “preg_split”.

Obviously, I am missing something in the difference between the two - would appreciate being pointed in the right direction.

Here are two example of existing SPLIT uses, I would like to change to preg_split.

FIRST:


split("[\\/]", $path);

if I change this to the following it works, 
explode("\\\\", $path);

but I would like to know why preg_split doesn't work.

SECOND:

split('[\\\\/]', $file);

I found the following solution and it appears to work.


split("[\\/]", $path);
should become
preg_split("_[\\\\\\\\/]_",$path);

The same preg_split regex works with both scenerios.

If anybody has a better solution, of if they know of a reason this solution is not good - please let me know!