mrgrammar;10986855 wrote:Why would it work with explode and not preg_split?
The pattern you gave [man]preg_split/man was empty; all it contained was an opening delimiter and then a closing delimiter immediately after it. It's essentially the same as doing:
explode('',$catname)
which PHP properly informs you is not possible due to the empty delimiter. Apparently, preg_split() offers no such warning in the case of a valid-but-empty PCRE.
mrgrammar;10986855 wrote:Is there a problem with the code above?
Yup, two problems. The first is the one I noted above.
The second is that you're using [man]preg_split/man when [man]explode/man should be used instead. 😉