Im trying to convert words into URLs. the words are separated with a comma ,. But my problem is that the first word is not taken into account, because there is no comma infort of it.
public static function convertHashtags($str){
$regex = "/,+([a-zA-Z0-9_]+)/";
$str = preg_replace($regex, '<a href="'.Config::get('URL').'index/hashtag/$1">$0</a>', htmlentities($str));
return($str);
}
For example $str=june,mars,april results that only mars and april get URLed, not june.