仅显示数组中的第一个索引(PHP)

I am trying to loop and display all the contents of my array, but the problem is, when I use a counter, the code only returns the first letter of the first index word in the array and if I removed the counter, only the first index of the array is displayed.

This is my code:

$query = $this->chartsData->missingPerRegion();
$region_name = array();
$missing_num = array();

$count = 0;

foreach($query->result_array() as $row){
    $regionQuery = $this->chartsData->getRegions($row['affected-population_region_id']);

    foreach($regionQuery->result_array() as $region){
        $region_name = $region['name'];
    }

    $missing_num = $row['missing'];
}

while($count < count($region_name) && $count < count($missing_num)){
    echo '{"label": "' . $region_name[$count] . '", "value": ' . $missing_num[$count] . '},';
    // Outputs '{"label": "R", "value": 0},'
    // Expected Output: '{"label: "Region X", "value": 0}, {"label: "RegionXI", "value": 10}, ...'
    $count++;
}

Anyone who knows how to solve this problem?

You are overwriting the region name that you store in the $region_name variable in every iteration of your inner foreach loop. You need to collect the individual region names instead:

 foreach ($regionQuery->result_array() as $region) {
    $region_name[] = $region['name'];
}

Notice the [] after the $region_name variable. This means that we are pushing each region name to the end of that array, instead of overwriting the variable in each iteration.