Replace All Occurrences of a Substring in a String using PHP

str_replace function

<?php

$text = 'abc def ghi abc';
$result = str_replace('abc', '123', $text);

echo $result; // 123 def ghi 123

Leave a Comment

Cancel reply

Your email address will not be published.