Re: function for $array
| From: | Marek Kilimajer | Date: | Fri, 21 Mar 2003 08:55:39 +0000 |
| Subject: | Re: function for $array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140560@lists.php.net to get a copy of this message | ||
I would use foreach instead of for, your function does not guarantie checking all elements and also checks elements that might not have been set.
pei_world wrote:
I want to use the following function the test the array elements, if all element is number return true, otherwise false; but the command marked, it print out only the first char of every strings in the array; can help? ie: ++0++ for 0.234 function check_int_float($array){$result=true;for($i=0; $i<sizeof($array); $i++){echo "++".$array[$i]."++"; <<<==================if($array[$i]!=""){ if(is_numeric($array[$i])){$result=true; }else{ $result=false;break; }//if }//if }//foreach return $result; } -- Sincerely your; pei_world ( .::IT::. )