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
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Mon Sep 06, 2004 12:38 pm
I've tried to create a regular expression which should replace the following:
{%download=img%}
into:
/p/dl/\\1={$res['id']}
{$res['id']} should be the contents of $res['id'] (right now set as 4 for example).
Here's what I currently have:
Code: Select all
<?php
$inc_out = preg_replace ("/\{%download=(.*)%\}/", "/p/dl/\\1={$res['id']}", $inc_out);
?>
but it doesn't work, i get this as the result:
it should result in:
Thanks in advance
Last edited by
vigge89 on Mon Sep 06, 2004 1:29 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Sep 06, 2004 1:25 pm
Code: Select all
<?php
$inc_out = preg_replace ("/\{%download=(.*?)%\}/", "/p/dl/\\\\1={$res['id']}", $inc_out);
?>
Last edited by
feyd on Mon Sep 06, 2004 1:30 pm, edited 1 time in total.
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Mon Sep 06, 2004 1:28 pm
I believe you forgot something ("/p/dl/
\\1 ={$res['id']}")
but i tried the pattern out, and it seems to work, thanks
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Mon Sep 06, 2004 1:31 pm
that part got hidden when the highlighter went over it.