Use str_replace() with an array and a count variable in PHP

Description

The following code shows how to use str_replace() with an array and a count variable.

Example


/* ww  w .j  a  va2s  .  c om*/
<?php
    $arr = array("blue","red","green","yellow");
    print_r(str_ireplace("RED","pink",$arr,$i)); // This function is case-insensitive
    echo "Replacements: $i";
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone