954,180 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need help to search string beginning for http://

Hello everyone! First of all thanks to all who helped in the past on my c++ problems, but now I need help with some php. I'm trying to search the beginning of a string for the http:// string but am having trouble with it. I can find the string inside the string but can't find it at the beginning of the string. In my attached code I wrapped a strpos() function inside of a substr() function and am trying to search the start of the string and stop the search after the http:// characters. I've tried changing the number of characters from 0 to 1 and 7 to 6 because strings start at 0 I suppose? Also, what about using JavaScript to check instead? although I'd rather use php. Any help would be greatly appreciated. Thank you!

$start = 0;
$end = 6;
$string = "http://";
if (substr(strpos($url, '$string'), '$start', '$end') === false ) {

die("Link must begin with http://");
}
c++learner
Light Poster
27 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

By the way, just thought that I would tell you that I'm not getting any syntax errors with this code, it's just not working.
Hello everyone! First of all thanks to all who helped in the past on my c++ problems, but now I need help with some php. I'm trying to search the beginning of a string for the http:// string but am having trouble with it. I can find the string inside the string but can't find it at the beginning of the string. In my attached code I wrapped a strpos() function inside of a substr() function and am trying to search the start of the string and stop the search after the http:// characters. I've tried changing the number of characters from 0 to 1 and 7 to 6 because strings start at 0 I suppose? Also, what about using JavaScript to check instead? although I'd rather use php. Any help would be greatly appreciated. Thank you!

$start = 0;
$end = 6;
$string = "http://";
if (substr(strpos($url, '$string'), '$start', '$end') === false ) {

die("Link must begin with http://");
}
c++learner
Light Poster
27 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

One more thing, I have to stop for now and won't be on until late tonight, so I'll check back then.
Thank you for your help.Hello everyone! First of all thanks to all who helped in the past on my c++ problems, but now I need help with some php. I'm trying to search the beginning of a string for the http:// string but am having trouble with it. I can find the string inside the string but can't find it at the beginning of the string. In my attached code I wrapped a strpos() function inside of a substr() function and am trying to search the start of the string and stop the search after the http:// characters. I've tried changing the number of characters from 0 to 1 and 7 to 6 because strings start at 0 I suppose? Also, what about using JavaScript to check instead? although I'd rather use php. Any help would be greatly appreciated. Thank you!

$start = 0;
$end = 6;
$string = "http://";
if (substr(strpos($url, '$string'), '$start', '$end') === false ) {

die("Link must begin with http://");
}
c++learner
Light Poster
27 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You