PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Wed Apr 14, 2004 11:09 pm
I'm trying to get the value of \\1 into a function.
My code:
Code: Select all
$this->body = preg_replace("#\[attachment=(.*?)\]#si", attachment("\\1"), $this->body);
I need to get the value of \\1 into the attachment() function. I'm sure it's possible, any help?
Last edited by
phice on Thu Apr 15, 2004 7:30 am, edited 1 time in total.
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Thu Apr 15, 2004 7:30 am
Thanks!
For future reference (visitors looking for a default answer), here's the code that I used:
Code: Select all
$this->body = preg_replace_callback("#\[attachment=(.*?)\]#si", create_function('$matches', 'return attachment($matches[1]);'), $this->body);
malcolmboston
DevNet Resident
Posts: 1826 Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK
Post
by malcolmboston » Thu Apr 15, 2004 7:38 am
omg phice i love you
ive had this problem for weeks!!!!
full steam ahead!!!
phice
Moderator
Posts: 1416 Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:
Post
by phice » Thu Apr 15, 2004 10:32 pm
\\1 returns the value of the first (hint: 1) (.*?) in the first set of quotes.