kucing Posted December 19, 2006 Share Posted December 19, 2006 Dear friends,I am having trouble solving this matter..[color=red]If someone help me how to get data like this one:[/color]aUtobiOgraphY, he wasn't, miLk shaKe, oVer driVe, losE mY breAth[color=red]Into this:[/color][url=http://aUtobiOgraphY]aUtobiOgraphY[/url], [url=http://he wasn't]he wasn't[/url], [url=http://miLk shaKe]miLk shaKe[/url], [url=http://oVer driVe]oVer driVe[/url], [url=http://losE mY breAth]losE mY breAth[/url]I saw many sites has this, like eg: http://www.friendster.com/user.php?uid=17053208if you look into "Favorite Movies"And ya I has some result but it only works when I do output using print command but when i try to get result using tpl .. i only get "Array" and nothing else Link to comment https://forums.phpfreaks.com/topic/31280-solvedimplode-or-explode-help-please/ Share on other sites More sharing options...
The Little Guy Posted December 19, 2006 Share Posted December 19, 2006 This is just an example:[code]$strings = array("aUtobiOgraphY", "he wasn't", "miLk shaKe", "oVer driVe", "losE mY breAth");foreach($strings as $string){ echo'<a href="http://mysite.com/'.$string.'">'.$string.'</a>';}[/code] Link to comment https://forums.phpfreaks.com/topic/31280-solvedimplode-or-explode-help-please/#findComment-144741 Share on other sites More sharing options...
esukf Posted December 19, 2006 Share Posted December 19, 2006 [code]<?phpfunction string_to_links($string, $url){ $string_array = array(); $link_str = ''; $string_array = explode(", ", $string); $count = count($string_array); for($i=0; $i < $count; $i++) { //replace non alphanumeric with spaces $valid_url_str = preg_replace('/\W/', ' ', $string_array[$i]); //build links and replace spaces with underscore $link_str .= '<a href="'.$url.str_replace(' ', '_', $valid_url_str).'">'.$string_array[$i].'</a>'; if($i < ($count-1)) { $link_str .= ', '; } } return $link_str;}$string = "aUtobiOgraphY, he wasn't, miLk shaKe, oVer driVe, losE mY breAth";$url = 'http://www.example.com/test.php?id=';echo string_to_links($string, $url);?>[/code] Link to comment https://forums.phpfreaks.com/topic/31280-solvedimplode-or-explode-help-please/#findComment-144766 Share on other sites More sharing options...
kucing Posted December 20, 2006 Author Share Posted December 20, 2006 Thanks everyone to help me :) Link to comment https://forums.phpfreaks.com/topic/31280-solvedimplode-or-explode-help-please/#findComment-145374 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.