Check string for "http://" and add it if it doesn't have it

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nusaki
Forum Newbie
Posts: 1
Joined: Thu Apr 08, 2010 11:14 am

Check string for "http://" and add it if it doesn't have it

Post by nusaki »

Hello I'm new with php and need some help
I have string ($string) how to check it if starts with "http://" and if it doesn't change it so it does.
Thank you
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Check string for "http://" and add it if it doesn't have

Post by requinix »

Use strncasecmp to check if something starts with something else. (Use the shorter length for the $len.)
Post Reply