I'm coming over from VB and I'm trying a few things to get my feet wet in PHP and I've ran into my first problem.
My goal is to take the text from a textarea and format each row into a single line separated by commas.
For example:
If the textarea contains
"1
2
3
4"
I would like to output to be "1,2,3,4"
The following is my code:
Code: Select all
<?php
echo "<Form action='index.php' method='get'>";
echo "<textarea name='Box' rows='10' cols='25'></textarea>";
echo "<input type='submit'/>";
echo "</form>";
$StrVar = $_GET['Box'];
$StrVar = str_replace(" ", ",", $StrVar);
echo $StrVar;
?>I tried replacing "%0D%0A" instead of " " as that is what appears in the browser. However, that did not work either. I do not possess the knowledge/tools yet to figure out why this isn't working, my hunch is that the php stores a different value for that space and I don't know what it is. Or perhaps the $StrVar is not being defined as a string so str_replace does not work? Any help with this would be greatly appreciated.