文字列の改行文字を削除

テキスト処理文字列

特徴

 閲覧数:1208  投稿日:2018-04-26  更新日:2018-05-16  

OS非依存


コード

$str = 'PHP
デモ';
echo $str;
$str = str_replace(PHP_EOL,'', $str);
echo $str;



結果

P H P デ モP H P デ モ



タグ


str_replace 



「半角スペースもしくは全角スペースで区切られた文字列」先頭に指定文字列を付与

文字列の中で変数展開される要件