PHP: str_replace

Posted in PHP
str_replace($search,$replace,$subject)

All instances of $search are replaced with $replace in $subject.

// Will print to screen: "Why is the sky blue?". 
echo str_replace("red","blue","Why is the sky red?")

Related PHP Posts

January 2025

Ensuring a smooth deployment of a PHP website application

Deploying a PHP website application requires meticulous planning, a solid understanding of the environment, and a thorough execution process. To ensure a smooth deployment, it...

Continue reading

June 2024

Popular PHP frameworks

Here’s detailed look at some of the most popular PHP frameworks, each of which can help speed up development, improve code organisation, and enhance application...

Continue reading

March 2024

PHP Security in 2024: navigating the evolving landscape

As PHP continues to evolve, so do the threats that target its vulnerabilities. Ensuring robust PHP security practices is paramount to safeguarding sensitive data and...

Continue reading

December 2022

Quick start guide for Laravel on a PHP server

Laravel is a powerful and popular PHP framework designed to make web development easier and more efficient. This quick start guide will help you set...

Continue reading

August 2021

Google Sheets to PHP array

This PHP function accepts a public Google Sheets URL and converts it into a PHP array. You can use the array to either display the...

Continue reading

March 2021

PHP cURL Requests with JSON or XML

The following post will explain how to use PHP/cURL to retrieve data in JSON or XML and process it for using in your PHP application...

Continue reading

More PHP Posts