I have written a PHP code that fetches website images from my other website (both are on separate hosting)
$listings['pic'][$count] = $critem[2];
The $critem[2]
sometimes returns either 1 or 2
1. https://www.example.com/wp-content/plugins/featured-content-gallery/scripts/mootools.v1.11.js
2. /wp-content/uploads/2017/07/Sidetracks-Main-1.jpg
What I am trying to do is Find
http://www.example.com
and replace with https://www.example.com
and if there is no domain in the $critem[2]
as in the (2nd example) append https://www.example.com
to the string
I am stuck as str_replace
does not work in this criteria