[SOLVED] Searching for text enclosed within square brackets
Posted: Mon Jun 21, 2004 2:32 pm
I have a script which needs to search a variable (which is from a mysql database e.g $row['text']) for any text which is enclosed by square brackets.
I have had a go at creating this however it doesnt put the text in the correct array, also when i try to echo out $matches[0] or any other array element it comes back with nothing.
Any ideas?
I have had a go at creating this however it doesnt put the text in the correct array, also when i try to echo out $matches[0] or any other array element it comes back with nothing.
Code: Select all
<?php
$text1 = $row['public'];
$regex = '/\[.*\]/i';
preg_match_all($regex, $text1, $matches);
?>