How can the PHP documentation be utilized effectively to troubleshoot issues with functions like preg_replace()?

To troubleshoot issues with functions like preg_replace(), it is essential to refer to the PHP documentation for detailed information on the function's parameters, usage, and examples. By understanding the correct syntax and options available, you can effectively troubleshoot and resolve any issues with preg_replace().

$pattern = '/\s/';
$replacement = '-';
$string = 'Hello World';
$result = preg_replace($pattern, $replacement, $string);
echo $result; // Output: Hello-World