$input = "mi perro quiere jugar"; $output = split(' ', $input); foreach($output as $x) { echo "<a href=\"miweb.com/".$x."/\">".$x."</a>"; }