Eh!regi_replace()
Posted: Sat Dec 06, 2003 11:10 am
Would someone be kind enough to explain why the following ereg isn't working. I'm too hot on the whole ereg thing yet but most of my other stuff is working... it's just this which is being a pain in the rear.
I think it's a problem with the square brackets, PHP isn't spitting out any errors which I guess means that the 'search pattern' is wrong.
Thanks.
Code: Select all
<?php
$string = "Hello. This is me.. [image=http://www.site.com/image.jpg] whoo!";
$f = "\\[image=([^\\]]+)\\]";
$t = "<img src="\\1" alt="" />";
$string = eregi_replace($f, $t, $string);
echo $string;
// Should echo().....
//
// Hello. This is me.. <img src="http://www.site.com/image.jpg" alt="" /> whoo!
//
// .....but doesn't
?>Thanks.