Jump to content

String trim and date problem


bundy

Recommended Posts

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 advance
Bundy
Link to comment
https://forums.phpfreaks.com/topic/14288-string-trim-and-date-problem/
Share on other sites

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.com
echo stripWWW('google.com'); // echo google.com
echo stripWWW('www.www.net'); // echo www.net

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.