Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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);
?>

Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #string #replace #regex
ADD COMMENT
Topic
Name
5+7 =