zimmo Posted July 2, 2010 Share Posted July 2, 2010 I am using some old code etc.. and need to get the data into a nice xhtml compliant format for mobile. Now the issue I have is with the bold tags and italic tags. I want to replace them with strong and for the italics to strip it out completely. Here is what I have tried: $string = $abstract; $abstractrpl = strtr($string, 'b>', 'strong>'); // Now the problem is, it does change them, but I dont get the correct tag, it is showing as: <st So I only get the first 2 characters? Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/ Share on other sites More sharing options...
Zane Posted July 2, 2010 Share Posted July 2, 2010 what's wrong with str_replace Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/#findComment-1080221 Share on other sites More sharing options...
zimmo Posted July 2, 2010 Author Share Posted July 2, 2010 Have fixed it $abstract = str_replace('b>', 'strong>',$abstract); // One other thing, how can I also get it to change other characters within the same declaration? So to change not only the bold tags but also the italic tags? Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/#findComment-1080223 Share on other sites More sharing options...
Zane Posted July 2, 2010 Share Posted July 2, 2010 this is what's known as a regex situation.. whereas you'd use the regex equivalent to str_replace; which is preg_replace $abstract = preg_replace('b|i>', 'strong>',$abstract); // Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/#findComment-1080237 Share on other sites More sharing options...
zimmo Posted July 2, 2010 Author Share Posted July 2, 2010 Thanks for that. One other thing, I am unsure how to format the date to D/M/Y Here is the code for the date: echo ("<h4>".utf8_encode($start)." ".utf8_encode($finish)."</h4>"); I am not sure how you do this with the encoding? The start is a date and the finish is a date? Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/#findComment-1080248 Share on other sites More sharing options...
ChemicalBliss Posted July 2, 2010 Share Posted July 2, 2010 What is actually in these variables $start and $date, is it a standard m/d/y representation or a unix timestamp? -cb- Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/#findComment-1080255 Share on other sites More sharing options...
zimmo Posted July 2, 2010 Author Share Posted July 2, 2010 Hi the date is: 2010-07-10 just the normal date. THanks Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/#findComment-1080260 Share on other sites More sharing options...
ChemicalBliss Posted July 2, 2010 Share Posted July 2, 2010 Before you utf8_encode them, run a custom function on them, eg: echo ("<h4>".utf8_encode(stringdate_format($start,"d/m/y"))." ".utf8_encode(stringdate_format($finish,"d/m/y"))."</h4>"); The function would look something like: function stringdate_format($string, $format){ $timestamp = strtotime($string); return date($format, $timestamp); } Hope this Helps, -cb- Quote Link to comment https://forums.phpfreaks.com/topic/206510-changing-tags/#findComment-1080297 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.