-2

I have a variable $username that I substring from a url string, which I get from a file.

This is the output of var_dump($username):

"tring(18) "honorablevacuum87

if I set $username = "honorablevacuum87" and I var_dump it, I get:

string(17) "honorablevacuum87"

What is the problem. I am getting insane over this.

dsthetics
  • 287
  • 1
  • 7
  • 19
  • 2
    After Edit: those are different because the first one got a type (a blank space maybe) at the end of the string, used $myString = trim($myString); ? – Marco Mura Dec 15 '14 at 09:01

1 Answers1

0

The problem is that you have opened the file in binary mode instead of text mode, which means that no end-of-line translation is happening.

$fp = fopen('foo.txt', 'rt');
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358