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/ 8 3617
In article <o5********************************@4ax.com>,
Jochen Daum <jo*********@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
Hi
On Sun, 07 Mar 2004 23:19:53 GMT, CC Zona <cc****@nospam.invalid>
wrote: In article <o5********************************@4ax.com>, Jochen Daum <jo*********@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/
With total disregard for any kind of safety measures Jochen Daum
<jo*********@cans.co.nz> leapt forth and uttered: preg_replace("#...#ies", "\$this->somefunction('\\1','\\2')", $content);
That should work.
--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/
Hi Phil,
On Mon, 08 Mar 2004 02:03:25 -0600, Phil Roberts
<ph*****@HOLYflatnetSHIT.net> wrote: With total disregard for any kind of safety measures Jochen Daum <jo*********@cans.co.nz> leapt forth and uttered:
preg_replace("#...#ies", "\$this->somefunction('\\1','\\2')", $content);
That should work.
I tried that. I don't think so.
Jochen
--
Jochen Daum - Cabletalk Group Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces. http://sourceforge.net/projects/phpdbedittk/
Jochen Daum wrote: I'd like to use something like
preg_replace("...","$this->somefunction('\\1','\\2');", $content);
It says "Cannot find function somefunction()"
Any ideas?
Maybe this helps ...
<?php
class XClass {
function somefunction($a, $b) {
echo 'a = ', $a, '; b = ', $b, "\n";
}
function anotherfunction() {
preg_replace('/(.)-(.)/ies', '$this->somefunction(\'\1\', \'\2\')', 'three-four');
}
}
$x = new XClass;
preg_replace('/(.)-(.)/ies', '$x->somefunction(\'\1\', \'\2\')', 'three-four');
$x->anotherfunction();
?>
Output is:
a = e; b = f
a = e; b = f
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
With total disregard for any kind of safety measures Jochen Daum
<jo*********@cabletalk.co.nz> leapt forth and uttered: Hi Phil, On Mon, 08 Mar 2004 02:03:25 -0600, Phil Roberts <ph*****@HOLYflatnetSHIT.net> wrote:
With total disregard for any kind of safety measures Jochen Daum <jo*********@cans.co.nz> leapt forth and uttered:
preg_replace("#...#ies", "\$this->somefunction('\\1','\\2')", $content);
That should work.
I tried that. I don't think so.
Jochen
Well then I think you tried it wrong, as I copied that
implementation from a working example.
--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/
Phil Roberts wrote: With total disregard for any kind of safety measures Jochen Daum <jo*********@cabletalk.co.nz> leapt forth and uttered: Hi Phil, On Mon, 08 Mar 2004 02:03:25 -0600, Phil Roberts <ph*****@HOLYflatnetSHIT.net> wrote:With total disregard for any kind of safety measures Jochen Daum <jo*********@cans.co.nz> leapt forth and uttered:
preg_replace("#...#ies", "\$this->somefunction('\\1','\\2')", $content);
That should work. I tried that. I don't think so.
Well then I think you tried it wrong, as I copied that implementation from a working example.
Is this inside a method of a class that defines somefunction() as
another of its methods?
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
With total disregard for any kind of safety measures Pedro Graca
<he****@hotpop.com> leapt forth and uttered: Is this inside a method of a class that defines somefunction() as another of its methods?
Yes. Here is the original source (taken from the invision board code):
$txt = preg_replace( "#\[url\](\S+?)\[/url\]#ie", "\$this->regex_build_url(array('html' => '\\1', 'show' => '\\1'))", $txt );
The 'e' switch after the regex string instructs preg_replace to
evaluate the replacement string as PHP code.
--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Richard B. Christ |
last post by:
I wrote the following code and it does NOT seem to work.
$search = array('/<popup*>/ie');
$replace = array('make_popup(split_tag(\\0))');
preg_replace($search, $replace, $someText);
If I try...
|
by: yawnmoth |
last post by:
say i have the following script:
<?
$test = "aaaaa";
print '"' . preg_replace('/.*/','x',$test) . '"<br>';
$test = "\n\n\n\n\n";
print '"' . preg_replace('/.*/','x',$test) . '"';
?>
the...
|
by: brendan |
last post by:
trying to clear out all text between the outermost
<---Message Start--->
and
<---Message End--->
tags
using snippet
|
by: yawnmoth |
last post by:
Can anyone help me understand the following scripts output?:
<?
echo preg_replace('/.*/e',"sprintf('\\\\\')",'');
?>
The output is \ and this doesn't make a lot of sense to me.
Since \\'s...
|
by: rybasso |
last post by:
Hello,
Does anyone has an idea why preg_replace() cause 'This page contains no
data' in FF and 'This page could not be found' in IE.
I spend a lot of time searching any ideas on newsgroups but...
|
by: =?iso-8859-2?B?SmFuIFJpbmdvuQ==?= |
last post by:
Hello everybody,
this is my first post to a newsgroup at all.
I would like to get some feedback on one proposal I am thinking about:
--- begin of proposal ---
Proposal to add...
|
by: Gilles Ganault |
last post by:
Hello
I went through some examples, tried a bunch of things... but still
can't figure out why I can't extract the TITLE section of a web page
using preg_replace():
-----------
<?php
$url...
|
by: amygdala |
last post by:
Hi there,
I'm trying to replace single quoted attributes in HTML tags with double
quotes. What I've come up with is this:
function replaceSingleQuotesInsideTags( $input )
{
$output =...
|
by: Sebarry |
last post by:
Hi,
I'm a PHP newbie and I don't understand what it means about the e modifier makes preg_replace() treat the replacement parameter as PHP code after the appropriate references substitution is...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| | |