
September 26th, 2002, 03:28 PM
|
|
|
|
Join Date: Apr 2007
Posts: 132
Time spent in forums: < 1 sec
Reputation Power: 2
|
|
|
String Replace Problem
OK, another minor problem - let's hope it is as easy to solve as the first...
I have a string which might look something like the following:
php Code:
Original
- php Code |
|
|
|
<?php $string = "This is my favourite picture, [img=funny.gif]My Family[/img]. Do you like it? How about this: [img=test.gif]Cool image[/img] How about that one?"; ?>
What I want to do is replace all the information in the [ img] (space added in the tag to prevent eF from picking it up) tags with the html <img> tag so that the attribute in the tag after the = is the image source, and the information between the tags is the alternative text, e.g.:
php Code:
Original
- php Code |
|
|
|
[img= file.gif ]Alt Text [/img ] becomes: <img src="file.gif" alt="Alt Text" />
I've tried using eregi_replace(), but I'm really not good with patterns and am not exactly sure how to do it. Any ideas would be great. Thanks in advance.
|