preg_replace http with https
php, preg-replace
Solution
Why not `str_replace` ?
$url="http://www.google.com"; // example http url ##
$url = str_replace('http://', 'https://', $url );
echo $url;
Problem
Put simply, I need to check if the string in the variable $url is a simple http, if so, replace it with https - but I can't get it to work - any ideas: ``` $url="http://www.google.com"; // example http url ## $url_replaced = preg_replace( '#^http://#','https://', $url ); // replace http with https ## ``` Cheers!