Bit of a newb with PHP, I'm trying to count records in a multi-dimensional array that contain a certain string in the second column.
The code I have is:
So basically I have an array called $results and I want to count how many records have the string Settlement in the second column of each row. However, the code above is returning zero everytime, although there are around 200 records that should match.
The array is definitely populated, I have a print loop straight after the code above that prints all records.
TBH, I'm not even sure if the code above is the correct way to go about this, so any help/advice appreciated.
Thanks
The code I have is:
Code:
$total = 0;
for($i = 0; $i < count($results); $i++)
{
if($results[$i][1] == 'Settlement')
{$total = $total + 1;}
}
echo $total;
So basically I have an array called $results and I want to count how many records have the string Settlement in the second column of each row. However, the code above is returning zero everytime, although there are around 200 records that should match.
The array is definitely populated, I have a print loop straight after the code above that prints all records.
TBH, I'm not even sure if the code above is the correct way to go about this, so any help/advice appreciated.
Thanks