Compare string in php file and string from cli

68 Views Asked by At

when I get input from cli, I var_dump it and this showed for me:

    string(2) "Y
"

So how I understand I receive the single char and the bag of blank spaces, so this code will return false ($input == "Y"). How I can solve this issue?

1

There are 1 best solutions below

2
On BEST ANSWER

You can easily remove all this whitespace using trim()

(trim($input) == 'Y')