lxndr Posted November 8, 2007 Share Posted November 8, 2007 I'm trying to write a function that will read in a text document containing various bespoke tags which I then expand into the appropriate HTML. I've done most of them but was wondering if someone could help me with this particular one .. I'm guessing I should be using preg_replace but can't seem to get it to work. I have a variable called $rec_id which is an integer. The following is the conversion I want to perform: in text file: <image 1/jpg> should be converted to : <img src = "story_images/1347-1.jpg" style="float:left;padding:5px;"> where the conversion string is all fixed as above apart from the bit in colour and in the above example $rec_id was 1347. Here are another couple of examples to illustrate the above: $rec_id: 1281 tag in text file: <image 2/gif> tag replaced with: <img src = "story_images/1281-2.gif" style="float:left;padding:5px;"> $rec_id: 763 tag in text file: <image 4/jpg> tag replaced with: <img src = "story_images/763-4.jpg" style="float:left;padding:5px;"> Any help much appreciated. . Link to comment https://forums.phpfreaks.com/topic/76594-text-substitution-help-needed/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.