Create an array with all the links of the years’ archive (of a custom post type)

I just recieved this answer in the StackOF page and it worked, though I don’t fully understand it.

 $links = wp_get_archives(array('echo'=>'0','format'=>'<link>'));
  $regex = '/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i';
  preg_match_all($regex, $links, $matches);
  $array_links = $matches[0];
  print_r($array_links);

Just added 'post_type' => 'myCPT' in the wp_get_archives() array and it worked.

Get to the real answer: https://stackoverflow.com/a/69365466/16825540