How can regular expressions be used to replace multiple spaces with a single space in PHP?
To replace multiple spaces with a single space in PHP using regular expressions, you can use the `preg_replace` function. You can create a regular expression pattern that matches one or more spaces and replace them with a single space.
$string = "This is a test string";
$cleaned_string = preg_replace('/\s+/', ' ', $string);
echo $cleaned_string;