PHPチュートリアル

PHPホーム PHPイントロ PHPインストール PHP構文 PHPコメント PHP変数 PHPエコー/印刷 PHPデータ型 PHP文字列 PHP番号 PHP数学 PHP定数 PHP演算子 PHP If ... Else ... Elseif PHPスイッチ PHPループ PHP関数 PHP配列 PHPスーパーグローバル PHP正規表現

PHPフォーム

PHPフォーム処理 PHPフォームの検証 PHPフォームが必要 PHPフォームのURL / Eメール PHPフォームの完了

PHP Advanced

PHPの日付と時刻 PHPインクルード PHPファイルの処理 PHPファイルのオープン/読み取り PHPファイルの作成/書き込み PHPファイルのアップロード PHPクッキー PHPセッション PHPフィルター PHPフィルターアドバンスト PHPコールバック関数 PHP JSON PHPの例外

PHPOOP _

PHPOOPとは PHPクラス/オブジェクト PHPコンストラクター PHPデストラクタ PHPアクセス修飾子 PHPの継承 PHP定数 PHP抽象クラス PHPインターフェース PHPの特性 PHP静的メソッド PHPの静的プロパティ PHP名前空間 PHPIterables

MySQLデータベース

MySQLデータベース MySQLコネクト MySQL Create DB MySQLテーブルの作成 MySQLの挿入データ MySQLは最後のIDを取得します MySQL Insert Multiple MySQLを準備しました MySQL Select Data MySQL Where MySQL Order By MySQLデータの削除 MySQLアップデートデータ MySQL制限データ

PHP XML

PHPXMLパーサー PHPSimpleXMLパーサー PHPSimpleXML-取得 PHP XMLExpat PHP XML DOM

PHP -AJAX

AJAXイントロ AJAX PHP AJAXデータベース AJAX XML AJAXライブ検索 AJAXポール

PHPの

PHPの例 PHPコンパイラ PHPクイズ PHP演習 PHP証明書

PHPリファレンス

PHPの概要 PHP配列 PHPカレンダー PHPの日付 PHPディレクトリ PHPエラー PHP例外 PHPファイルシステム PHPフィルター PHP FTP PHP JSON PHPキーワード PHP Libxml PHPメール PHP数学 PHPその他 PHP MySQLi PHPネットワーク PHP出力制御 PHP正規表現 PHP SimpleXML PHPストリーム PHP文字列
addcslashes() addlashes() bin2hex() チョップ() chr() チャンクスプリット() convert_cyr_string() convert_uudecode() convert_uuencode() count_chars() crc32() crypt() エコー() explode() fprint() get_html_translation_table() hebrev() hebrevc() hex2bin() html_entity_decode() htmlentities() htmlspecialchars_decode() htmlspecialchars() implode() 加入() lcfirst() レーベンシュタイン() localeconv() ltrim() md5() md5_file() metaphone() money_format() nl_langinfo() nl2br() number_format() words() parse_str() print() printf() quoted_printable_decode() quoted_printable_encode() quotemeta() rtrim() setlocale() sha1() sha1_file() 類似のテキスト() soundex() sprintf() sscanf() str_getcsv() str_ireplace() str_pad() str_repeat() str_replace() str_rot13() str_shuffle() str_split() str_word_count() strcasecmp() strchr() strcmp() strcoll() strcspn() strip_tags() stripcslashes() stripslashes() 漫画 () ストリップ() strlen() strnatcasecmp() strnatcmp() strncasecmp() strncmp() strpbrk() strpos() strrchr() strrev() strripos() strrpos() strspn() strstr() strtok() strtolower() strtoupper() strtr() substr() substr_compare() substr_count() substr_replace() トリム() ucfirst() ucwords() vfprintf() vprintf() vsprintf() ワードラップ()
PHP変数の処理 PHPXMLパーサー PHP Zip PHPタイムゾーン

PHP str_ireplace()関数

❮PHP文字列リファレンス

文字列「Helloworld!」の文字「WORLD」(大文字と小文字を区別しない)を置き換えます。「ピーター」と:

<?php
echo str_ireplace("WORLD","Peter","Hello world!");
?>

定義と使用法

str_ireplace()関数は、文字列内の一部の文字を他の一部の文字に置き換えます。

この関数は、次のルールに従って機能します。

  • 検索する文字列が配列の場合、配列を返します
  • 検索する文字列が配列の場合、すべての配列要素に対して検索と置換が実行されます
  • findとreplaceの両方が配列であり、replaceの要素がfindより少ない場合、空の文字列がreplaceとして使用されます
  • findが配列で、replaceが文字列の場合、replace文字列がすべての検索値に使用されます

注:この関数では大文字と小文字は区別されません。str_replace()関数を使用 して、大文字と小文字を区別する検索を実行します。

注:この関数はバイナリセーフです。


構文

str_ireplace(find,replace,string,count)

パラメータ値

Parameter Description
find Required. Specifies the value to find
replace Required. Specifies the value to replace the value in find
string Required. Specifies the string to be searched
count Optional. A variable that counts the number of replacements


技術的な詳細

戻り値: 値が置き換えられた文字列または配列を返します
PHPバージョン: 5歳以上
変更ログ: countパラメーターはPHP5.0で追加されまし

その他の例

配列とカウント変数でstr_ireplace()を使用する:

<?php
$arr = array("blue","red","green","yellow");
print_r(str_ireplace("RED","pink",$arr,$i)); // This function is case-insensitive
echo "Replacements: $i";
?>

findよりもreplaceの要素が少ないstr_ireplace()を使用する:

<?php
$find = array("HELLO","WORLD");
$replace = array("B");
$arr = array("Hello","world","!");
print_r(str_ireplace($find,$replace,$arr));
?>

❮PHP文字列リファレンス