|
Posted by Jerry Stuckle on 08/18/06 02:56
mens libertina wrote:
> Jerry Stuckle wrote:
>
>>No, you can also make it a global in the function and not pass it as a parm.
>>
>>The one thing to remember - variable names in a function are only known
>>within that function. They can't be used outside of it.
>>
>>Global variables can be used anyplace.
>
>
>
> OK, I used the global keyword and verified it (via print_r() ) in the
> function, but I get nothing when I add print statements to
> preg_replace_callback() :
>
> $tagpatt = '/\{(\w+?)\}/';
> $emesg = preg_replace_callback( $tagpatt,
> create_function( '$matches',
> 'print_r($matches);print_r($info);$field=strtolower($matches[1]);return
> $info[$field];' ),
> $emesg );
>
>
> It seems like p_r_c() can't do what I want, but it's seems to be
> designed for just this type of backreference manipulation. Am I just
> going about this the wrong way?
>
Yes, it can do what you want. The question is - are you getting any
matches? I'm far from an expert on regex's, but it looks like you
aren't getting any matches.
If the code is as you indicate, you should, however. What happens if you
print $tagpart and $emesg?
Also - do you get any output after the call to preg_replace_callback
(just to make sure there isn't a runtime error you aren't seeing)?
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|