Page 1 of 1

check size of an array

Posted: Tue Nov 25, 2008 4:36 am
by mit
I need to check size of an array which is in this format : $dref="score1;score2;score3;score4";
I need to check the size of this array if the score2,score3,score4 are empty return me 1 if score3,score4 are empty return me 2 , meaning to check how many of scores are having value.

like -> $dref="19;;;; "; = return me 1
$dref="19;18;;; "; =return me 2
$dref="19;18;40;; "; = return me 3
$dref="19;18;40;50; "; = return me 4(all)

Re: check size of an array

Posted: Tue Nov 25, 2008 4:41 am
by papa
count()

Re: check size of an array

Posted: Tue Nov 25, 2008 4:43 am
by mit
how can i use this count()? count will return me non empty one or all?

Re: check size of an array

Posted: Tue Nov 25, 2008 4:53 am
by aceconcepts
count will returnt he number of values in an array - http://uk3.php.net/count

Take a look at the PHP manual http://uk.php.net/array

Re: check size of an array

Posted: Tue Nov 25, 2008 6:35 am
by Mark Baker
mit wrote:I need to check size of an array which is in this format : $dref="score1;score2;score3;score4";
This isn't actually an array. It's a string.

Code: Select all

 
$dref = "score1;score2;score3;score4";
$drefArray = explode(';',$dref);
echo '<pre>';
print_r($drefArray);
echo '</pre>';
 
Then start looking at the array functions described in the manual