Jump to content

[SOLVED] Splitting list by symbol


EchoFool

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.