Answers for "php string replace regex"

PHP
0

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
2

preg_replace

<?php
$string = 'April 15, 2003';
$pattern = '/(\w+) (\d+), (\d+)/i';
$replacement = '${1}1,$3';
echo preg_replace($pattern, $replacement, $string);
Posted by: Guest on August-02-2020
0

php preg_replace function

preg_replace($pattern, $replacement, $string);
Posted by: Guest on May-01-2020

Code answers related to "php string replace regex"

Browse Popular Code Answers by Language