/ Published in: PHP

takes a url and appends http to it if http is not present
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// takes a url and appends http to it if http is not present function check_http($link){ $findme = 'http'; // Note our use of ===. Simply == would not work as expected because the position of 'a' was the 0th (first) character. if ($pos === false) { //echo "The string '$findme' was not found in the string '$mystring'"; $full_link = "http://".$link; } else { //echo "The string '$findme' was found in the string '$mystring' and exists at position $pos"; $full_link = $link; } return $full_link; }
Comments
