PHP Textarea (for each)

Ok, im stuck and cannot figure this out.

I have a text area on my page and i will be putting a list of words in there one per line. When it posts it needs to put it in an arry so i can put each of those words in the database as a seperate result.

I can figure out how to put it in the database but here is my issue. If i type like this:

entry1
entry2

entry3
entry4

It then takes that space and stores it in the database. Is there anyway to strip out an Empty line so it doesnt effect my database query?

This is Kinda how i have it…

[php]

<?php $text = $_POST["text"]; $lines = explode("r",$text); $num = count($lines); for($i=0;$i<$num;$i++) { $var1 = $lines[$i]; $var = str_replace('r', '', $var1); echo $var; } ?>

[/php]

Even in that code it keeps the extra line in the result. Any ideas?

Sponsor our Newsletter | Privacy Policy | Terms of Service