Before I explain how to use the filter extension to validate Boolean values in arrays, as well as how to check float numbers, I'm going to review quickly the set of examples developed during the preceding article. Those were aimed at illustrating how to utilize the FILTER_VALIDATE_BOOLEAN filter to check whether or not the value assigned to a given variable is Boolean. Having said that, here's how these examples were created originally. Take a look at them, please:
// example on validating Boolean TRUE values with the FILTER_VALIDATE_BOOLEAN filter
echo filter_var(1, FILTER_VALIDATE_BOOLEAN); // displays 1 echo filter_var('1', FILTER_VALIDATE_BOOLEAN); // displays 1 echo filter_var(TRUE, FILTER_VALIDATE_BOOLEAN); // displays 1 echo filter_var('TRUE', FILTER_VALIDATE_BOOLEAN); // displays 1 echo filter_var(true, FILTER_VALIDATE_BOOLEAN); // displays 1 echo filter_var('true', FILTER_VALIDATE_BOOLEAN); // displays 1 echo filter_var('on', FILTER_VALIDATE_BOOLEAN); // displays 1 echo filter_var(true, FILTER_VALIDATE_BOOLEAN); // displays 1
// example on validating Boolean false values with the FILTER_VALIDATE_BOOLEAN filter
echo filter_var(0, FILTER_VALIDATE_BOOLEAN); // displays nothing echo filter_var('0', FILTER_VALIDATE_BOOLEAN); // displays nothing echo filter_var(FALSE, FILTER_VALIDATE_BOOLEAN); // displays nothing echo filter_var('FALSE', FILTER_VALIDATE_BOOLEAN); // displays nothing echo filter_var('off', FILTER_VALIDATE_BOOLEAN); // displays nothing echo filter_var(NULL, FILTER_VALIDATE_BOOLEAN); // displays nothing echo filter_var('NULL', FILTER_VALIDATE_BOOLEAN); // displays nothing
To be frank, determining whether a PHP variable has been assigned a Boolean value with the FILTER_VALIDATE_BOOLEAN filter is actually a no-brainer process that can be tackled with minor hassles. As you probably recall, the examples listed above show how this filter behaves when used with different values that will be evaluated either as TRUE or FALSE. So far, so good. At this point I'm sure that you're familiar with using the filter extension to validate Boolean data types. So, the next step that I'm going to take will consist of explaining how to check Boolean values in arrays, in this case by means of the "filter_var_array()" function that you learned in previous installments of the series. This topic will be discussed in more detail in the next section. Therefore, to learn more about it, please click on the link that appears below and read the next few lines.
blog comments powered by Disqus |
|
|
|
|
|
|
|