I am using: $url = "http://" . str_replace("https://", "", str_replace("http://", "", str_replace("www.", "", $passedurl ))); PHP: To clean up URLs, that may I can make sure it is an actual URL A. is this going to be a good check B. How can I clean it up so that I am not doing a triple search and replace?
php has a function called parse_url which breaks a url into its constituent parts and stores them in an array. You can then examine/replace any part you want, and recombine whichever pieces you want to keep into a string. Far better to rely on php for this than to try and split it yourself. man page here: php.net/manual/en/function.parse-url.php