Forum Moderators: coopster

Message Too Old, No Replies

Stripping a URL

         

Tom_Cash

5:06 pm on Jan 19, 2009 (gmt 0)

10+ Year Member



Hi there,
I currently have a function on one of my websites where a user can add a myspace link to their profile. I specifically ask for just their username/id so that I can auto link to it from their profile.

Obviously, however, I still get people completely ignoring this and going for full URL's.

So, I was wondering if there was a more effective approach available alternativly to the one I am using?

Here's my code.

$remove_fields = array("http://", "www.", "myspace", ".com", ".co.uk", "/");
$replace_fields = array("", "", "", "", "", "");

$user_myspace_stripped = str_replace($remove_fields, $replace_fields, $user_myspace);

Kindest regards,
Tom.

supermanjnk

7:05 pm on Jan 19, 2009 (gmt 0)

10+ Year Member



you could look into the basename() [us.php.net] function in php

Tom_Cash

9:21 am on Jan 20, 2009 (gmt 0)

10+ Year Member



Hi supermanjnk,
Thanks for the help! :)