I need a way to split a string, devided by comma (,) or new line and to display each word as a link. There is a similar request of 2007 ( [
webmasterworld.com...] ), which is closed to commenting, so opening a new one.
The following code works fine for me:
<?php
$array = explode(" ",$item['view']);
foreach ($array as $word) { print '<a href="/word/'.trim($word, ',.«»').'">'.$word.'</a> ';} ?>
However, with this code works for plaint text only. And I really would like to use this for the string that already contains some links or other html codes like <strong>, <b>, etc, and I would like them to be escaped. How can I do it?
[edited by: coopster at 3:41 pm (utc) on Jan 12, 2011]
[edit reason] fixed link [/edit]