preg_replace_callback, how to use in object ?

preg_replace_callback, how to use in object ?

am 14.04.2008 15:34:28 von Snaggy

this is my problem:

Class myClass {

function process($matches) {return something($matches);}

function myReplace($input)
{
return preg_replace_callback(/pattern/, '$this->process', $input)
}
}

problem is '$this->process' isn't a valid callback.

How can I do this?

Re: preg_replace_callback, how to use in object ?

am 14.04.2008 15:57:13 von zeldorblat

On Apr 14, 9:34 am, Snaggy wrote:
> this is my problem:
>
> Class myClass {
>
> function process($matches) {return something($matches);}
>
> function myReplace($input)
> {
> return preg_replace_callback(/pattern/, '$this->process', $input)
>
> }
> }
>
> problem is '$this->process' isn't a valid callback.
>

No, but this is:

array($this, 'process')