Dysan
11-29-2007, 02:12 PM
How do I check if an array already exists?
|
Click to See Complete Forum and Search --> : Array Exists? Dysan 11-29-2007, 02:12 PM How do I check if an array already exists? NogDog 11-29-2007, 02:21 PM isset (http://www.php.net/isset)() will tell you if the variable exists. If you then need to verify that it is an array, use is_array (http://www.php.net/is_array)(). Znupi 11-29-2007, 02:21 PM if (is_array($array)) { // This tests if $array is an array } // or... if (count($array)) { // This tests if there is any data in the array $array. // If $array is undefined, count($array) will return 0, and this block of code won't get executed // if $array is defined, but is not an array and let's say it's a string, for example, count($array) will return 1 and this block will be executed } // or.... if ( is_array($array) && count($array) ) { // This tests if $array is an array and if it has any data in it. } Hope this helps :) selvam4win 11-29-2007, 03:29 PM Thx it is very useful for me webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |