Remove new line characters from text file using php

I have txt file its content like this

Hello
World
John
play
football

I want to delete the new line character when reading this text file, but I don't know how it look like the file .txt and its encoding is utf-8


There are different kind of newlines. This will remove all 3 kinds in $string:

$string = str_replace(array("\r", "\n"), '', $string)