CKTIS / PHP
str_ireplace()
Zastępuje dosłowne dopasowania, ignorując wielkość liter ASCII.
Wersja: PHP 8.4; repository runtime, production runtime not attested
Składnia
str_ireplace(array|string $search, array|string $replace, array|string $subject, int &$count = null): array|stringZastępuje dosłowne dopasowania, ignorując wielkość liter ASCII. Od PHP 8.2 nie zależy to od ustawień regionalnych i nie obejmuje wszystkich liter Unicode. count odbiera łączną liczbę zamian, a wynik dla tablicy zachowuje jej klucze.
Sygnatura
str_ireplace(array|string $search, array|string $replace, array|string $subject, int &$count = null): array|string
Wynik przykładu
[{"a":"XX","b":"X"},3,"É"]
Przykłady
<?php
$out=str_ireplace("ab","X",["a"=>"ABab","b"=>"Ab"],$count);
echo json_encode([$out,$count,str_ireplace("\u{00E9}","x","\u{00C9}")],JSON_UNESCAPED_UNICODE);
Wynik
[{"a":"XX","b":"X"},3,"É"]