PHP curl SFTP files list to array? [duplicate]

I am using the code below to get all files from a folder via curl sftp.

$ch = curl_init('sftp://' . $sftpServer . ':' . $sftpPort . $sftpRemoteDir . '/');
        
curl_setopt($ch, CURLOPT_USERPWD, '*******:*******');
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_SFTP);
curl_setopt($ch, CURLOPT_DIRLISTONLY, '1L');
$response = curl_exec($ch);

I have tried explode() and preg_match() but for some reason I can't parse the list of results:

641265471.txt_20220103_220501
641269117.txt_20220103_230501
..

How can I actually parse the data above to each new line being an array item ?


I completely forgot to add

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

which is needed to capture the response.