Page is a not externally linkable
- Code, Content, and Presentation
-- PHP Server Side Scripting
---- value between square brackets


TheMadScientist - 12:40 am on Jan 1, 2010 (gmt 0)


Although the posted solution works, depending on the length of the entire string involved it ranges from slightly inefficient to beyond the time most have to do the math for to determine the lack of efficiency...

I would recommend:
preg_match("/\[([^\]]+)\]/", $title , $matches);

Which matches [, followed by 'IsNotABracket', followed by ].

The reason is if the string you are trying to find the match in continues beyond the closing bracket the .* matches the entire string, then has to work backward and forward until all possible matches are found, then the best match is chosen... For more detailed information, see the linked thread or the PHP preg manual.

[webmasterworld.com...]


Thread source:: http://www.webmasterworld.com/php/4048935.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com