Answers for "replace character in string with regex php"

PHP
1

php string replace regex

<?php
$string = 'The quick brown fox jumps over the lazy dog.';
$patterns = array();
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements = array();
$replacements[2] = 'bear';
$replacements[1] = 'black';
$replacements[0] = 'slow';
echo preg_replace($patterns, $replacements, $string);
?>
Posted by: Guest on May-30-2021

Code answers related to "replace character in string with regex php"

Browse Popular Code Answers by Language