Search
 
SCRIPT & CODE EXAMPLE
 

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

Comment

PREVIOUS NEXT
Code Example
Php :: count sql query in php 
Php :: php artisan down 
Php :: laravel new model 
Php :: convert a php array into a javascript array 
Php :: twig ternary 
Php :: newline in php 
Php :: get key by value array php 
Php :: php validate date format 
Php :: laravel limit query pagination 
Php :: create user with tinker php laravel 
Php :: php subtract date from today 
Php :: if text contains word then in php 
Php :: wp enqueue style for style.css 
Php :: laravel gigapay 
Php :: nav active in laravel 
Php :: php body_class wp 
Php :: what is directory_separator in php 
Php :: php echo alot of html 
Php :: how to create new project in laravel 
Php :: laravel collection random 
Php :: laravel 8 date difference in days 
Php :: setcookie 
Php :: laravel make directory 
Php :: round numnero php 
Php :: php open csv 
Php :: php change string to url friendly 
Php :: wordpress truncate text 
Php :: php round() function 
Php :: php curl async callback 
Php :: php add to array in loop 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =