How does PHP handle multiple spaces in a string passed through $_POST?

When a string with multiple spaces is passed through $_POST in PHP, the spaces may be automatically trimmed or reduced to a single space. To preserve the multiple spaces, you can use the PHP function `htmlspecialchars()` to encode the string and then decode it using `htmlspecialchars_decode()` when needed.

// Fix for handling multiple spaces in a string passed through $_POST
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $inputString = $_POST["input"];
    $encodedString = htmlspecialchars($inputString, ENT_QUOTES);
    
    // Use $encodedString in your processing
    
    // When needed, decode the string
    $decodedString = htmlspecialchars_decode($encodedString, ENT_QUOTES);
}