mahtabpi's avatar

Explain ex of str_ireplace() function !

I don't underestand this example about str_ireplace() function , can anybody explain about it ?

$find = array("HELLO","WORLD"); // Case-insensitive $replace = array("B"); $arr = array("Hello","world","!"); print_r(str_ireplace($find,$replace,$arr));

result : Array ( [0] => B [1] => [2] => ! )

0 likes
2 replies
tomopongrac's avatar
Level 51

If you want to replace second item than you must provide second item in replace

$find = array("HELLO","WORLD"); // Case-insensitive
$replace = array("B", "T");
$arr = array("Hello","world","!");
print_r(str_ireplace($find,$replace,$arr));

// result
Array
(
    [0] => B
    [1] => T
    [2] => !
)

http://php.net/manual/en/function.str-ireplace.php

1 like

Please or to participate in this conversation.