php で配列内の文字列を置換する方法: [str_replace("red","pink",$arr,$i)] など、str_replace 関数を使用して置換できます。検索対象の文字列が配列の場合は、配列内の各要素を検索して置換します。
str_replace(find,replace,string,count)
<!DOCTYPE html> <html> <body> <?php $arr = array("blue","red","green","yellow"); print_r(str_replace("red","pink",$arr,$i)); echo "<br>" . "Replacements: $i"; ?> <p>In this example, we search an array to find the value "red", and then we replace the value "red" with "pink".</p> </body> </html>
php ビデオ チュートリアル)
実行結果:#関連する推奨事項:
以上がPHPで配列内の文字列を置換する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。