使用php从mysql获取唯一标签和出现次数

there is a "post" table in mysql and column "tags".

Tags' value is like apple,orange,peach,etc.

I'm trying to get all the tags and assign tag & number of occurances to array using php. Here is what I am trying to do.

$recmostusedtagscol = array();
$recmostusedtagsq = mysqli_query($connecDB,"select tags from post limit 5");
while($recmostusedtagsr = mysqli_fetch_array($recmostusedtagsq)){
  $tagsarray = explode(',', $recmostusedtagsr['tags']);
  foreach ($tagsarray as $tag) {
    if(in_array($tag,$recmostusedtagscol)){
      $recmostusedtagscol[$tag][]++;
    }
    else {
      $recmostusedtagscol .= [$tag => 1];
    }
  }
}
print_r($recmostusedtagscol);

UPDATED: this one is close. It is listing uniqe values, but it is not adding plus 1 to the array value.

$recmostusedtagscol = array();
$recmostusedtagsq = mysqli_query($connecDB,"select tags from post");
while($recmostusedtagsr = mysqli_fetch_array($recmostusedtagsq)){
  $tagsarray = explode(',', $recmostusedtagsr['tags']);
  foreach ($tagsarray as $tag) {
    if(in_array($tag,$recmostusedtagscol)){
      $recmostusedtagscol[$tag]++;
    }
    else {
      $recmostusedtagscol[$tag]=1;
    }
  }
}
print_r($recmostusedtagscol);

it seems in_array() is not working.... maybe....

Based on the comments, here is the working one.

$recmostusedtagscol = array();
$recmostusedtagsq = mysqli_query($connecDB,"select tags from post");
while($recmostusedtagsr = mysqli_fetch_array($recmostusedtagsq)){
  $tagsarray = explode(',', $recmostusedtagsr['tags']);
  foreach ($tagsarray as $tag) {
    if(isset($recmostusedtagscol[$tag])){
      $recmostusedtagscol[$tag]++;
    }
    else {
      $recmostusedtagscol[$tag]=1;
    }
  }
}

Thanks to @Mark Baker and @arkascha