Friday, April 29, 2016

Replace multiple values from string using arrays in PHP

- You can pass multiple values in array as parameters to the str_replace function.


// Result: I love to develop static websites using HTML and CSS

$string  = "I love to develop dynamic websites using PHP and Mysql";        
$string_words = array("dynamic", "PHP", "Mysql");
$new_string_words   = array("static", "HTML", "CSS");
echo $new_string = str_replace($string_words, $new_string_words, $string);

No comments:

Post a Comment

MySQL: SELECT * FROM `table_name` WHERE start and end date within two dates

My query should include the following: Everything that starts between 2018-03-04 and 2018-03-10 Everything that is due between 2018-03-0...