Cultureshock Posted January 7, 2010 Share Posted January 7, 2010 I have a table that holds info. One column in particular holds tags( while(mysql_fetch_array($example)){aka $tags=['tags']}; ) which are separated by commas (ex. $tags= love, hate, like, dislike). I want to turn this string into an array to link each seperated word into links <a href="?tag=love">love</a> <a href="?tag=hate">hate</a> etc I thought doing while(explode(",", $tags)){ echo "<a href='?tag=".$tag."'>".$tag."</a>";}; would work but instead it takes the page a long time to load, and once it DOES load, the first tag is repeated 100s of times. Assistance, please I don't know if the problem is in the while(explode()) or if it's in something else related to the $tags, but everything else not exploded is working correctly, soo. Link to comment https://forums.phpfreaks.com/topic/187619-failing-at-using-explode-help/ Share on other sites More sharing options...
trq Posted January 7, 2010 Share Posted January 7, 2010 You don't want the actual explode within your while expression. Post your actual code. Link to comment https://forums.phpfreaks.com/topic/187619-failing-at-using-explode-help/#findComment-990569 Share on other sites More sharing options...
taith Posted January 7, 2010 Share Posted January 7, 2010 or at least not a while()... foreach(array('love','hate','like','dislike') as $v) echo $v; foreach(explode(',','love,hate,like,dislike') as $v) echo $v; Link to comment https://forums.phpfreaks.com/topic/187619-failing-at-using-explode-help/#findComment-990571 Share on other sites More sharing options...
Cultureshock Posted January 7, 2010 Author Share Posted January 7, 2010 Foreach worked! Thanks so much, I didn't remember foreach()... if I had I'd have used it Thanks again! Link to comment https://forums.phpfreaks.com/topic/187619-failing-at-using-explode-help/#findComment-990597 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.