I've a function in symfony 3.4 which throws chars that do not exist in file:
use Exception;
use phpseclib\Net\SFTP;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\VarDumper\VarDumper;
public static function getInfoFile(string $fileName, ContainerInterface $container)
{
$host = $container->getParameter('host');
$sftp = new SFTP($host);
if (!$sftp->login($container->getParameter('user'), $container->getParameter('pass'))) {
throw new Exception('Cannot connect to ' . $host);
}
$file = $sftp->get("/info/$fileName");
vardumper::dump($file); // See Response below
$file = preg_split('/\R/', $file);
reset($file);
// vardumper::dump($file); // This would now return each array element prepended with b"""
return $file;
}
This returns:
Service.php on line 30: b""" A;B;C;D;E;F\r\n 1;2;3;4;5;6\r\n
This b""" is nowhere in the file. I've tried to open with Notepad++ and Excel and this cannot be seen.
When I try to use substr with this, then b""" stays and real file is cut.
What am i doing wrong? I would like to read the csv file for each line into an array without these cryptic b"""