str_replace()


string str_replace ( string $search, string $replace, string $subject [ , int &$count ] )

Description

str_replace() replaces some characters with some other characters in a string.

※ available F/W version : all

Parameters

Return values

Returns a string with the replaced values, PHP error on error

Example

<?php
$search = "Mark";
$replace = "John";
$subject = "His name is Mark. Mark is handsome.";
$count = 0;
$ret = "";

$ret = str_replace($search, $replace, $subject, $count);
echo "count: $count, ret: $ret\r\n"; // OUTPUT: count: 2, ret: His name is John. John is handsome.
?>

See also

str_repeat() / strpos() / substr() / substr_replace()

Remarks

This function is identical to the PHP group’s str_replace() function but doesn’t support array.