My latest issue involves trying to find “http://” in a variable. This variable contains the contents of a comments section on a clients website. I have seen all kinds of answers but none of them seem to work. I looked at a few other posts on here and I have yet to get the best answer. Here is what I have so far:
if(strpos($comments, 'http://') == true) {
// Does stuff here
}
I noticed other people use preg_match and some said to do it in an array. I am getting confused, too many options. Just kidding. I would like some clarification though and any advice would be greatly appreciated.
You’ll need to say:
…since it can return 0 (which is falsey) if
http://is at the beginning of the string.NOTE: This will only find the first occurrence of
http://in the string.Take a close look at the reference: http://php.net/manual/en/function.strpos.php