4
Contributors
5
Replies
7
Views
5 Years
Discussion Span
Last Post by apanimesh061
0

str_pos() returns boolean (TRUE or FALSE). Should be

if (strpos($html->href, 'http://') !== FALSE) {
    //there is http in the url, then do this statement
    // your code
}

Or use @diafol method.

1

str_pos() returns boolean (TRUE or FALSE)

Incorrect. It returns the index (starting from 0) at which the needle was found in the haystack.

If the needle wasn't found, it returns false. Hence why you need to test for absolutely equal to false, rather than equal to false to avoid false positives if 0 is returned.

Votes + Comments
Thanks for correcting.
0
if (strpos($link->href, 'http://') === 0) {
        array_push($urlarray, $link->href);
    }

I have corrected that ... "===" was to be used rather than "==" or "<=" etc.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.