preg_replace with e modifier, how to use class function

This is a discussion on preg_replace with e modifier, how to use class function within the PHP Language forums, part of the PHP Programming Forums category; Hi, I'd like to use something like preg_replace("...","$this->somefunction('\\1','\\2');", $content); It ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-07-2004
Jochen Daum
 
Posts: n/a
Default preg_replace with e modifier, how to use class function

Hi,

I'd like to use something like

preg_replace("...","$this->somefunction('\\1','\\2');", $content);

It says "Cannot find function somefunction()"


I tried some escaping, but didn't work.

Any ideas?

Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Reply With Quote
  #2 (permalink)  
Old 03-08-2004
CC Zona
 
Posts: n/a
Default Re: preg_replace with e modifier, how to use class function

In article <o59n40t486rjkbncbn5lvrug7vq94uc4tq@4ax.com>,
Jochen Daum <jochen.daum@cans.co.nz> wrote:

> preg_replace("...","$this->somefunction('\\1','\\2');", $content);
>
> It says "Cannot find function somefunction()"
>
>
> I tried some escaping, but didn't work.
>
> Any ideas?


Have you tried preg_replace_callback <http://php.net/preg-replace-callback> yet? The user notes contain several examples of calling class methods.

--
CC
Reply With Quote
  #3 (permalink)  
Old 03-08-2004
Jochen Daum
 
Posts: n/a
Default Re: preg_replace with e modifier, how to use class function

Hi

On Sun, 07 Mar 2004 23:19:53 GMT, CC Zona <cczona@nospam.invalid>
wrote:

>In article <o59n40t486rjkbncbn5lvrug7vq94uc4tq@4ax.com>,
> Jochen Daum <jochen.daum@cans.co.nz> wrote:
>
>> preg_replace("...","$this->somefunction('\\1','\\2');", $content);
>>
>> It says "Cannot find function somefunction()"
>>
>>
>> I tried some escaping, but didn't work.
>>
>> Any ideas?

>
>Have you tried preg_replace_callback <http://php.net/preg-replace-callback> yet? The user notes contain several examples of calling class methods.


Actually not. I expected that the callback gets the 'match' delivered,
which I expected to be a string, not an array.

Thanks anyway,

Jochen

--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:20 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0