Customizing SMF > SMF Coding Discussion

Regex help

<< < (2/2)

4Kstore:

--- Quote from: MrPhil on May 09, 2012, 02:17:34 PM ---How about

--- Code: ---$url_list = explode('|', $url);
$match = $url_list[4];
--- End code ---

This assumes that $url is the actual string as shown in your post. You may have to adjust the element number if it's just a part of that line.

--- End quote ---

Thanks, this is other option...

I dont know which is more effective and faster

MrPhil:
Exploding a string into an array is almost always faster than crawling through it trying to match a regular expression. The PHP manual recommends using explode() rather than preg_split() if your separator is a constant string.

manixless:

--- Quote from: MrPhil on May 09, 2012, 06:54:29 PM ---Exploding a string into an array is almost always faster than crawling through it trying to match a regular expression. The PHP manual recommends using explode() rather than preg_split() if your separator is a constant string.

--- End quote ---

total agree with you

Navigation

[0] Message Index

[*] Previous page

Go to full version