Hi all, I’m currently putting together a basic snippet to format the output of a text input TV for a dropdown list. For some reason though, my comma delimited list from the TV won’t explode. Also, I’m no PHP expert so if I’ve done something dumb please let me know!
Here’s my code:
// Create array variable from colourSelect TV
$cs_rawInput = "[*colourSelect*]";
$cs_colourList = explode(", ", $cs_rawInput);
// For each value in the array, print an option for a select box
foreach ($cs_colourList as $value) {
print "<option value=\"$value\">$value</option>";
};
Now, lets say the contents of my TV are "red, green, blue". Well, this string never explodes. That is, I get one dropdown option with "red, green, blue" in it.
However, for testing purposes, when I manually type in "red, green, blue" as a value for $cs_rawInput in my snippet, I get three separate dropdown options just like I want.
Does anyone have any idea why this is the case and what I might have done wrong? As far as I can tell, the string that my TV outputs is exactly the same as the one I manually type.