Are there best practices for preserving multiple spaces in PHP scripts when using $_POST?

When using $_POST in PHP scripts, multiple spaces in the input data may be trimmed by default, leading to potential data loss or formatting issues. To preserve multiple spaces, it is recommended to use the PHP function `htmlspecialchars` to encode the input data before processing it. This will ensure that the spaces are preserved and not trimmed.

$input_data = htmlspecialchars($_POST['input_field'], ENT_QUOTES);
// Process the input data with preserved multiple spaces