Forum Moderators: coopster

Message Too Old, No Replies

preg replace for href links

how do i use it example please?

         

Dilly

4:51 pm on Sep 12, 2007 (gmt 0)

10+ Year Member



Hi,
Can someone please give me an example of how i can use preg_replace for a link such as:

<?php

echo"<a href=\"make.php?id=$id&amp;modelname=$name\">$name</a>";

?>

to be changed to..

<?php

echo"<a href=\"make/$name-$id.html\">$name</a>";

?>

Thanx in advance!

Dilly

10:43 am on Sep 13, 2007 (gmt 0)

10+ Year Member



any one?

eelixduppy

2:20 pm on Sep 13, 2007 (gmt 0)



Is the code example above taken directly from your working script? If it is, I don't see why you would want to preg_replace anything when you are just echoing it to the browser. If this is the case, then you should just change the way it is echoed to follow the new format.

Dilly

10:10 am on Sep 14, 2007 (gmt 0)

10+ Year Member



Sorry bad example, how about ..

oldfolder/old.php?id=<?php echo $id;?>

to

newfolder/new/<?php echo $id;?>.php

[edited by: Dilly at 10:12 am (utc) on Sep. 14, 2007]