3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $text = "This is a #hashtag within some #awesometext."; function tagIt($body) { $string = $body; $htag = "#"; $newstring = preg_replace("/#(\w)+/g", "<a href='category.php?tag=$1'>#$1</a>", $string); //$arr = preg_split("/\s|\./", $string);print_r($arr); /*$arrc = count($arr); $i = 0; while($i < $arrc) { if(substr($arr[$i], 0, 1) === $htag) { $arr[$i] = "<a href = 'category.php?tag=".substr($arr[$i], 1)."'>".$arr[$i]."</a>"; } $i++; } $string = implode(" ", $arr);*/ echo "\n".$newstring."\n"; } tagIt($text);
Output for 4.3.11 - 7.1.0
Warning: preg_replace(): Unknown modifier 'g' in /in/HsM9M on line 9
Output for 4.3.0 - 4.3.10
Warning: Unknown modifier 'g' in /in/HsM9M on line 9