|
Posted by Umberto Salsi on 05/29/07 20:48
"Giovanni R." <linfo2003@NOSPAMlibero.it> wrote:
> Here it is how it could be used:
>
> print wrapper($array['inexistent_index']);
>
> In this way, even if $array['inexistent_index'] isn't defined, I don't
> get a notice. The fact is that wrapper() adds that index to the array
> and sets $array['inexistent_index'] to NULL. :-(
This code will say you all about the existence of the $array and its
element 'inexistent_index', also if this element is NULL:
if( isset($array) ){
echo "the array exists\n";
if( array_key_exists('inexistent_index', $array) ){
echo "the element array[inexistent_index] exists\n";
if( $array['inexistent_index'] === NULL ){
echo "...and it is NULL\n";
} else {
echo "...and it is not NULL\n";
}
} else {
echo "the element array[inexistent_index] does not exist\n";
}
} else {
echo "the array does not exist\n";
}
Regards,
___
/_|_\ Umberto Salsi
\/_\/ www.icosaedro.it
Navigation:
[Reply to this message]
|