EchoFool Posted January 30, 2009 Share Posted January 30, 2009 I have a script where im trying to split words by a comma but i do not know how to echo the words so that each time they echo the word is in a variable within the loop so it can be processed. This is what i tried: <?php $var = 'Banana,Apple,Orange,Grape'; $vars = split(",", $var); array_pop($vars); $row = array(); foreach ($vars as $var) { echo $var.'<br>'; } ?> Was hoping it would echo out like this: Banana Apple Orange Grape But nothing echoes. Where did i go wrong? Link to comment https://forums.phpfreaks.com/topic/143140-solved-splitting-list-by-symbol/ Share on other sites More sharing options...
lonewolf217 Posted January 30, 2009 Share Posted January 30, 2009 I think you may want to use explode() instead of split() <?php $var = 'Banana,Apple,Orange,Grape'; $vars = explode(",", $var); foreach ($vars as $var) { echo $var.'<br>'; } ?> will that work for you ? Link to comment https://forums.phpfreaks.com/topic/143140-solved-splitting-list-by-symbol/#findComment-750711 Share on other sites More sharing options...
EchoFool Posted January 30, 2009 Author Share Posted January 30, 2009 Yeah worked a treat thanks Link to comment https://forums.phpfreaks.com/topic/143140-solved-splitting-list-by-symbol/#findComment-750737 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.