This is a discussion on preg_replace_callback(), how to pass function argument/param? within the PHP General forums, part of the PHP Programming Forums category; Hi, This is probably simple to answer for most of ya'll, but... preg_replace_callback($f, 'mah_processTags', $text); Besides the matches, ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
This is probably simple to answer for most of ya'll, but... preg_replace_callback($f, 'mah_processTags', $text); Besides the matches, how would I pass function args/param to mah_processTags()? For example, I would like to do something like this: preg_replace_callback($f, 'mah_processTags($arg1)', $text); function mah_processTags($matches, $arg1) { ... } Is this even possible? I just want to pass-in $arg1 along with the matches. :) Possible? Many thanks in advance!!! Cheers, Micky -- Wishlist: <http://tinyurl.com/22xonb> Switch: <http://browsehappy.com/> BCC?: <http://snipurl.com/w6f8> My: <http://del.icio.us/mhulse> |
|
|||
|
On Sun, Mar 30, 2008 at 1:17 AM, Micky Hulse <micky@ambiguism.com> wrote:
> Hi, > > This is probably simple to answer for most of ya'll, but... > > preg_replace_callback($f, 'mah_processTags', $text); > > Besides the matches, how would I pass function args/param to > mah_processTags()? > > For example, I would like to do something like this: > > preg_replace_callback($f, 'mah_processTags($arg1)', $text); preg_replace_callback($f, 'mah_processTags(\'$0\', $arg1)', $text); Does this work? > function mah_processTags($matches, $arg1) { ... } > > Is this even possible? I just want to pass-in $arg1 along with the > matches. :) > > Possible? > > Many thanks in advance!!! > Cheers, > Micky > > -- > Wishlist: <http://tinyurl.com/22xonb> > Switch: <http://browsehappy.com/> > BCC?: <http://snipurl.com/w6f8> > My: <http://del.icio.us/mhulse> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- -Casey |
|
|||
|
Hi Casey! Many thanks for your help! I greatly appreciate it. :)
>> preg_replace_callback($f, 'mah_processTags($arg1)', $text); > preg_replace_callback($f, 'mah_processTags(\'$0\', $arg1)', $text); > Does this work? Ah, interesting... Thanks for the example code... I am at work now, but will try that as soon as I get home later tonight. Your code examp looks very promising -- I will let you know how it goes. A billion thanks! Cheers, Micky |
|
|||
|
Casey wrote:
> preg_replace_callback($f, 'mah_processTags(\'$0\', $arg1)', $text); > Does this work? Awww, does not seem to work. :( But maybe I need to dink with the code a bit more... I would like to avoid setting a global here. :D Thanks for the help Casey! I will let you know if I get it working. I may just have to think of a different approach here. Cheers, Micky -- Wishlist: <http://tinyurl.com/22xonb> Switch: <http://browsehappy.com/> BCC?: <http://snipurl.com/w6f8> My: <http://del.icio.us/mhulse> |
|
|||
|
On Sun, Mar 30, 2008 at 9:37 PM, Micky Hulse <micky@ambiguism.com> wrote:
> Casey wrote: > > preg_replace_callback($f, 'mah_processTags(\'$0\', $arg1)', $text); > > Does this work? > > Awww, does not seem to work. :( > > But maybe I need to dink with the code a bit more... > > I would like to avoid setting a global here. :D > > Thanks for the help Casey! I will let you know if I get it working. I > may just have to think of a different approach here. > > > > Cheers, > Micky > > Hmmm. I've searched around, and it seems that only a global would work :/ -- -Casey |
|
|||
|
Casey wrote:
> Hmmm. I've searched around, and it seems that only a global would work :/ Thanks for the help Casey! I really appreciate it. :) Yah, I think I will use a global for now... Until I can think of an alternative coding approach. Have a good one! Cheers, Micky -- Wishlist: <http://tinyurl.com/22xonb> Switch: <http://browsehappy.com/> BCC?: <http://snipurl.com/w6f8> My: <http://del.icio.us/mhulse> |
|
|||
|
On Sun, Mar 30, 2008 at 10:06 PM, Micky Hulse <micky@ambiguism.com> wrote:
> Casey wrote: > > Hmmm. I've searched around, and it seems that only a global would work :/ > > Thanks for the help Casey! I really appreciate it. :) > > Yah, I think I will use a global for now... Until I can think of an > alternative coding approach. > > Have a good one! > > > > Cheers, > Micky > > What does mah_process_tags do anyway? XD -- -Casey |
|
|||
|
Casey wrote:
> What does mah_process_tags do anyway? XD Ah, hehe... Oh, basically I am trying to write a plugin for the Textpattern CMS: <http://textpattern.com/> processTags() is a core TXP function... Basically, it parses any TXP template tags (<txp:function_name atts="foo" />). Long story short, I am am modifying the processTags() function so that it looks for class methods when parsing template tags, vs. looking for regular functions. Thanks again Casey! I really appreciate your help. :) Cheers, Micky -- Wishlist: <http://tinyurl.com/22xonb> Switch: <http://browsehappy.com/> BCC?: <http://snipurl.com/w6f8> My: <http://del.icio.us/mhulse> |
![]() |
| Thread Tools | |
| Display Modes | |
|
|