'PHP - Make PHP function output multiple instances

I have $tutorial->difficulty which sometimes has multiple outputs, and for each output that goes into the breakCommas function, I need to output a link for each one. Currently with how I have it, when $tutorial->difficulty outputs multiple items, it basically clumps them all into a single link. From what I've read I realize you can't have multiple outputs per function. Any ideas how I can separate it to where it outputs multiple links?

PHP

function breakCommas($str) {
  return ('<a href="'.str_replace(' ','-',strtolower($str)).'-tutorial">'.$str.'</a>');
}

HTML

<div>
  <?=breakCommas($tutorial->difficulty)?>
</div> 


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source