I have a combo box where the user selects files to delete. then I add a ".txt" to it so the user can delete a txt file of their choice.
Anyway this is what it returns:
myfile .txt
when there shouldn't be a space after the name and the .txt. Any ideas how to remove it?
combo box returning a space at the end?
Moderator: General Moderators
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
-
slipstream
- Forum Commoner
- Posts: 86
- Joined: Fri Apr 19, 2002 8:53 am
- Location: Canada
I suspect your $line is formatted something like "text you want | stuff you don't want". If that's right, when you call
it will leave the space in. Again, assuming my guess about the format is right, you could do
to get rid of the spaces, too.
If it isn't always " | ", you could explode on just "|" like you are and do something like:
when you make the box.
Code: Select all
<?php
explode("|", $line);
?>Code: Select all
<?php
explode(" | ", $line); // Note the spaces around the '|' character
?>If it isn't always " | ", you could explode on just "|" like you are and do something like:
Code: Select all
<?php
echo '<option value="'.trim($info[0]).'">'.trim($info[0]).'</option>';
?>