Help with variables/strings

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
jonizal
Forum Newbie
Posts: 1
Joined: Mon Dec 27, 2010 3:43 pm

Help with variables/strings

Post by jonizal »

i need to see if http:// exist in the first 7 chars in the var $link
how would i code this? with a if statement or something

Also i need it to add it to the beginning if it doesn't have http://

and one more thing i need it to search for a word and if it exist then it will give a error.

if anyone can help then thank you.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help with variables/strings

Post by califdon »

You can use strpos() to determine if the first 7 characters are "http://" (Ref: http://php.net/manual/en/function.strpos.php) and you can use the dot concatenation operator to modify the string if it doesn't.
Post Reply