I have a MySQL result that I want to safely output using PHP, i.e. converting special characters such as < to <.
filter_var_array works fine, except that NULL values turn into empty string ''.
I still want them to be NULL in order to reflect the MySQL value and to test with is_null() etc.
$sql_rows = filter_var_array($sql_rows, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
foreach ($sql_rows as $sql_row) {
print '<li>' . $sql_row['name'] . '</li>';
}
Any convenient way to achieve this?
1 Answer