...

View Full Version : Selecting a string from a variable



danielwarner
08-13-2007, 04:03 PM
What im looking to do is to extract the text from a variable such as a database query and search the text to effectively "highlight" a certain line so that i can perform more functions on the single line i highlighted.

What i mean is like when you use BB code in an input and the database entry says [l i n k] or [/l i n k] with the text to link in the middle. So what im looking for is an effective way of searching my database entry for this string.

Can anyone help here, im unsure of what to search for. All im looking for is a function to give me the "[l i n k] text text text [/l i n k]" so i can work on the string myself.

Thanks for your time

Fumigator
08-13-2007, 04:43 PM
This sounds like a job for regex, which you can do right inside your MySQL query with the keyword REGEXP (http://dev.mysql.com/doc/refman/4.1/en/regexp.html), or after the fact in PHP using preg_match() (http://us2.php.net/manual/en/function.preg-match.php) (and other similar functions).



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum