How can PHP scripts handle and display multiple spaces in strings when outputting HTML content?

When outputting HTML content, multiple spaces in strings can be collapsed into a single space by default. To preserve multiple spaces in the output, you can use the HTML entity ` ` for each space. This will ensure that all spaces are displayed as intended in the HTML output.

<?php
$string = "This   is   a   string   with   multiple   spaces";
$preservedString = str_replace(" ", " ", $string);
echo $preservedString;
?>