Answers for "string replace php match"

PHP
2

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
8

php replace string within string

$new_string = str_replace( $take_out, $put_in, $string);
Posted by: Guest on August-18-2020

Browse Popular Code Answers by Language