
ショコラ
PHP で配列の中の特定の文字(¥t)を置換するには?
array_walk関数でキメマス。

もっさん先輩
array_walk($array, fn(&$str) => $str = mb_ereg_replace("\t",' ',$str));
array_walk($array, function(&$str){ $str = mb_ereg_replace("\t",' ',$str); });
PHP5.2 以下は関数の定義が必要です。
if (!function_exists('replace_tab')) {
function replace_tab(&$str) {
$str= mb_ereg_replace("\t",' ',$str);
}
}
array_walk($item,'replace_tab');
PHP は function の中で、さらに function を定義することができます。
シチュエーション
タブ区切りのデータでリクエストするシステムがあった。しかし、データ(配列)の中にもタブが入っていてエラーになっていた。