Hard code to remove http://www.

gausarts - September 20, 2008 - 09:42
Project:Link
Version:6.x-2.3.1
Component:Miscellaneous
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I have a link with print $node->field_link[0]['url'], like this:
http://www.yoursite.com/bla/bla/bla

How to remove http://www. and /bla/bla/bla, so that I can grab only:
yoursite.com

It doesn't need to be linkable/ clickable at any rate. Any hint? Thanks

#1

dereine - September 20, 2008 - 14:26

i'm sure you can do it with regular expressions but using str_replace is all you need

<?php
$link
= $node->field_link[0]['url'];
$link = str_replace('http://www.', '', $link);
?>

This will be all

#2

gausarts - September 20, 2008 - 15:22
Status:active» fixed

I knew I could miss it:) Thanks for the hint

#3

Anonymous (not verified) - October 4, 2008 - 15:31
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.