What are some best practices for handling variable values that are not enclosed in quotes during text conversion to an array in PHP?

When handling variable values that are not enclosed in quotes during text conversion to an array in PHP, it is important to sanitize the input to prevent any potential security vulnerabilities or unexpected behavior. One way to do this is by using the `filter_var()` function with the `FILTER_SANITIZE_STRING` filter to ensure that the values are treated as strings. This helps to avoid any issues that may arise from unquoted values being interpreted as constants or keywords in PHP.

$input = "value1, value2, value3";
$values = array_map('trim', explode(',', $input));

// Sanitize the values to ensure they are treated as strings
$sanitized_values = array_map(function($value) {
    return filter_var($value, FILTER_SANITIZE_STRING);
}, $values);

print_r($sanitized_values);