----- Original Message -----
From: "pei_world" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, March 20, 2003 4:30 PM
Subject: [PHP] function for $array


> 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::. )


There are some (what I would call) "engineering" issues with your  function
but it looks like it should work.  Maybe your problem lies in the array?

// Cleaned up function..
function array_is_numeric($array)
{
 $result=true;
 for($i=0; $i<sizeof($array); $i++)
 {
   if(!is_numeric($array[$i]))
   $result=false;
 }
 return $result;
}

- Kevin



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to