![]() |
Picky explode()
I was browsing another forum earlier today and came across someone who wanted to split a string into an array. That's a fairly simple task with explode(). But they also wanted anything in between brackets to be left alone.
I came up with a solution that works fine, but I'm fairly certain there's a better way to do it. Here's what I've got. PHP Code:
|
You could probably do this with
preg_split, if we were clever enough. However, I for one am not. There are a few on TalkPHP which I'm sure are. This would be my solution:php Code:
|
Quote:
Code:
Array |
Yes, sorry, my bad. I forgot to put a line in a conditional statement. Try:
php Code:
|
Not too sure about using
preg_split but here's a possible regex solution:PHP Code:
|
| All times are GMT. The time now is 04:41 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0