Can I check the number of values in an array, for example...
$abc=array();
$abc[0]="asd";
$abc[1]="sadaf";
$abc[2]="sfadaf";
I want to check and store it(2) in a variable that array abc[] exists till $abc[2]..
Thanks
Can I check the number of values in an array, for example...
$abc=array();
$abc[0]="asd";
$abc[1]="sadaf";
$abc[2]="sfadaf";
I want to check and store it(2) in a variable that array abc[] exists till $abc[2]..
Thanks
Use count
or sizeof
for the total number of values or array_count_values
to count the frequency of each value.
$arraysize = sizeof($abc) - 1; // will be set to 2
if(isset($abc[$arraysize]))
{
$abcEndExists = true;
}
else
{
$abcEndExists = false;
}
Is this what you're looking for?
$minArrayIndex = 2;
$arrayCountTest = ((count($abc) - 1) >= $minArrayIndex) ? true : false;
This will assign $arrayCountTest
true if the array has elements of at least an index of 2.