PHP – Create user-defined function that calls str_replace, then calls ucfirst with the resulting string from str_replace

I’ve only recently started learning PHP and had an idea that I’ve been trying to figure out how, or if, it’s even possible.
The lesson I’m working on introduced str_replace and ucfirst, among other basic inbuilt functions.
After becoming familiar with basic code to use those functions, I started trying to figure out if I could create a function that does both.

PHP | Replicate specific word excluding the title attribute

I’m trying to replace the word “custom” and replicate it with <span> custom </span>.
With the str_replace () function it works but this also replaces it in the title attribute and I don’t want this to happen because the span tag inside the title is an error.
How can I replace the word “custom” without touching the title attribute?

Replacing inside body using PHP

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></head> <body></body>"; $homepage = substr($homepage, strpos($homepage, "<body>")); $homepage = preg_replace("/https://(.?)", "", $homepage); echo $homepage; Output : <head></body> The output i am looking for : <head></head> <body></body> I just … Read more