正規表現に一致する部分を置換します。
構文
preg_replace(string $pattern, string $replacement, string $subject): string|null使用例
下記の値を入力するとサンプルに即時反映されます。
str→echo→preg_replace→Hello→World→$str = "Hello World";
echo preg_replace('/s+/', ' ', $str); // Hello World