-3

I need a small part of helping, i can't remember the requlare exp. to tell me about its a URL or not, i need to tjeck about its starting whit http:// or not, befures if its not have http:// in start i need to put it into and if its have i need to do nothing.

Hobe sombardy can help me whit this queistion, and thanks a lot for helping.

Template 1:

<a href="http://myurl.com">Title 1</a>

Template 2:

<a href="www.myurl2.com">Title 2</a>
Alan Moore
  • 73,866
  • 12
  • 100
  • 156
ParisNakitaKejser
  • 12,112
  • 9
  • 46
  • 66

1 Answers1

1

Use preg_replace like this

$url = 'http://www.yahoo.com';
echo 'http://' . preg_replace( '~^http://~', '', $url );
chandresh_cool
  • 11,753
  • 3
  • 30
  • 45