What are the best practices for posting PHP code for review on forums?

Issue: I am trying to validate a user input against a list of allowed values in PHP. Code snippet:

$user_input = $_POST['user_input'];
$allowed_values = ['value1', 'value2', 'value3'];

if (in_array($user_input, $allowed_values)) {
    echo "User input is valid.";
} else {
    echo "User input is not valid.";
}