can anyone help with this? I have a web address as a variable and would like to replace multiple web address if they exist.
$value = (!empty($_SERVER['HTTPS']))
? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']
: "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
Say if part of the URLs exist within the variable, then replace with a different one. Maybe str_replace would be the best way but unsure how to do it with more than one possibility.
ie. If the following are to be stored, store https://www.url4.com/ instead.
This is the solution I found and the best way I have found.
setcookie($cookie_name, strstr($value, '/url-folder')
When setting the cookie use strstr which will remove everything before.
In my case this is being stored in a cookie and only require part of the URL. when echo the link concatenate the new address followed by the cookie value.