Jump to: navigation, search

Php str ireplace

From w3cyberlearnings

Contents

PHP function str_ireplace

This function replaces all occurrences of the search string with the replacement string. It is case insensitive. It is similar to str_replace() function.

Syntax str_ireplace

  • search: string to search for replace
  • replace: string to replace
  • count
str_ireplace (string, replace, count);

Example 1

<?php

$str = "You are a great leader";
$new_str = str_ireplace("great", "good", $str);
echo $new_str;
?>

Output

You are a good leader

Example 2

<?php
$str = "All you can eat, all you can say, all you can think.";
$new_str = str_ireplace("all", "nothing", $str, $count);

echo $new_str;
echo '<br/>';
echo 'Total Replace: ' . $count;
?>

Output

nothing you can eat, nothing you can say, nothing you can think.
Total Replace: 3

Related Functions


Navigation
Web
SQL
MISC
References