i am trying to replace inside body tag using PHP but every time i am getting different output than i expecting the one.
Try :
$homepage = "<head>https://www.example.com</head> <body>https://www.example.com</body>";
$homepage = substr($homepage, strpos($homepage, "<body>"));
$homepage = preg_replace("/https:\/\/(.?)+\.example\.com/", "https://www.example.net", $homepage);
echo $homepage;
Output :
<head>https://www.example.net</body>
The output i am looking for :
<head>https://www.example.com</head> <body>https://www.example.net</body>
I just want to change/replace the string inside tag.