Because your (result) array is not indexed, you are doomed to loop over it for each row of database data. This is very inefficient. For the same reason you index database tables, you need to index the data in your array. This allows you to directly test and reference any element in the array. Consider the following -
<?php
// overall goal appears to be counting the number of tickets at each priority level and counting each status at each priority level
// define possible indexes
$tkt_priority = [1];
$tkt_status = [1,2];
// because some priority/status indexes may not exist in the actual data, define a starting array with all possibilities
$counts = [];
foreach($tkt_priority as $priIndex)
{
foreach($tkt_status as $staIndex)
{
$counts[$priIndex]['total'] = 0; // note: if all status index values are included in the data, you don't need a separate total since the sum of the individual status values will be the total
$counts[$priIndex][$staIndex] = 0;
}
}
// examine the result
echo '<pre>'; print_r($counts);
// count the values in the data directly using an indexed array
foreach($loadMyDashboardDB as $row)
{
$counts[ $row['tkt_priority'] ]['total'] += 1; // see note above about a separate total
$counts[ $row['tkt_priority'] ][ $row['tkt_status'] ] += 1;
}
// examine the result
echo '<pre>'; print_r($counts);