Skip to content
Advertisement

PHP / Linux shell unwanted character

I have an HTML form (field with multiple lines) that feeds a PHP code that will read each line of the field, and generate a pdf file using the line string as name. My problem is that all but the last file have a trailing ‘?’ at the end of the file. I think that somehow the form is sending an special character to the variable and I can’t seem to remove it.

Here is a snippet of the code:

HTML:

JavaScript

PHP:

JavaScript

OK.. So if in the Form I type:

JavaScript

Run the script.. When I list the “out” folder this is what I get:

JavaScript

Question is, how do I remove this special character from the file names?

Thanks

Advertisement

Answer

most likely you’re passing “rn” linebreaks when submitting the form, so when you do a preg_split('/[n]+/', $emails); it leaves r symbol there, which is not printable, hence the ? character

To fix this, use rn in preg_split

JavaScript
Advertisement