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)
check size of an array
Moderator: General Moderators
Re: check size of an array
count()
Re: check size of an array
how can i use this count()? count will return me non empty one or all?
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: check size of an array
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
Take a look at the PHP manual http://uk.php.net/array
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: check size of an array
This isn't actually an array. It's a string.mit wrote:I need to check size of an array which is in this format : $dref="score1;score2;score3;score4";
Code: Select all
$dref = "score1;score2;score3;score4";
$drefArray = explode(';',$dref);
echo '<pre>';
print_r($drefArray);
echo '</pre>';