Forum Moderators: coopster

Message Too Old, No Replies

trouble with preg_match_all

not displaying info

         

reiqwan

3:10 pm on May 26, 2003 (gmt 0)

10+ Year Member



My data seems to be called up fine from the database when I echo it as soon as I apply a function which I got from php.net to clean up a string which is as follows:

Code:
Here is an explanation.
The "/" marks the begining of the expression.
The "\" says do not use the special meaning of the next character.
The "{" says find "{".
The "." says find any character.
The "*" says find zero or more of the previous character (which was any character).
The "?" says don't be "greedy," which means match as few characters as possible before the next element in the match.
The "\" says do not use the special meaning of the next character.
The "}" says find "}". And the "/" marks the end.
If you don't use the "?" you get a "greedy" match of everything from the first "{" to the last "}", "{tag1} and {tag2}" */

//Here is the function

function replacer($text)
{
preg_match_all( '/\{.*?\}/', $text, $tags );

foreach ($tags[0] as $loop_result)
{
echo $loop_result."";
}

$repinfo = "";

return $repinfo;
}
--> end of code

It doesn't show anything, does anyone know why this is happening and if so please help

thanks

jatar_k

3:37 am on May 27, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld reiqwan,

none of you regex folk want to take a shot at this?

reiqwan

7:19 am on May 27, 2003 (gmt 0)

10+ Year Member



im not too sure that I get what youre saying?

ruserious

9:08 am on May 27, 2003 (gmt 0)

10+ Year Member



The function works fine for me with an example like:

"something {to check} out"

it echoes "{to check}"

Can you give an example where it is not working? Also use the [ code] [/ code] tags when you're posting code. ;)