bundy Posted July 11, 2006 Share Posted July 11, 2006 Hi,I'm using a referral script on my page and it looks like this[quote]11/07/06, 12:48 www.blablabla.com 11/07/06, 12:31 www.blablabla.org 11/07/06, 12:27 www.blablabla.be 11/07/06, 12:24 www.blablabla.nl 11/07/06, 12:21 www.blablabla.be 11/07/06, 12:18 blablabla.com 11/07/06, 12:13 www.blablabla.com 11/07/06, 12:03 www.blablabla.be 11/07/06, 12:00 blablabla.be 11/07/06, 12:00 www.blablabla.be [/quote]is there a way to remove the www. on the referrals (that have one of course). So in other words I need a script that deletes a certain follow up of chars (in this case www.) in a given string.have another question about the date this time.it's generated by this code (it's a phpbb forum)[code]'LAST' => create_date($board_config['default_dateformat'], $row['referrer_lastvisit'], $board_config['board_timezone']))[/code]is it possible to drop the date and only display the time?thanks in advanceBundy Quote Link to comment https://forums.phpfreaks.com/topic/14288-string-trim-and-date-problem/ Share on other sites More sharing options...
GingerRobot Posted July 11, 2006 Share Posted July 11, 2006 <?php$string = "www.test.com";echo substr_replace($string, '', 0,4);?> Quote Link to comment https://forums.phpfreaks.com/topic/14288-string-trim-and-date-problem/#findComment-56153 Share on other sites More sharing options...
kenrbnsn Posted July 11, 2006 Share Posted July 11, 2006 You can also use plain str_replace()[code]<?php$str = 'www.test.com';echo str_replace('www.','',$str);?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/14288-string-trim-and-date-problem/#findComment-56156 Share on other sites More sharing options...
hvle Posted July 11, 2006 Share Posted July 11, 2006 There is no universial rule to strip those www. but you can write a function.it's simple and safe:function stripWWW($str){ $pattern = substr($str, 0,4); if (strcasecmp($pattern,'www.') == 0) return substr($str,4); else return $str;}echo stripWWW('www.google.com'); // echo google.comecho stripWWW('google.com'); // echo google.comecho stripWWW('www.www.net'); // echo www.net Quote Link to comment https://forums.phpfreaks.com/topic/14288-string-trim-and-date-problem/#findComment-56157 Share on other sites More sharing options...
bundy Posted July 11, 2006 Author Share Posted July 11, 2006 [quote author=kenrbnsn link=topic=100188.msg395090#msg395090 date=1152623383]You can also use plain str_replace()[code]<?php$str = 'www.test.com';echo str_replace('www.','',$str);?>[/code]Ken[/quote]that worked perfectly! many thanks to everyone! Quote Link to comment https://forums.phpfreaks.com/topic/14288-string-trim-and-date-problem/#findComment-56159 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.