Re: replacing null values and line breaks in file




windandwaves wrote:
Hi Gurus

I want to replace null values with a space and line breaks with a |
symbol in a file. I have written the following function:

function replace_characters($path, $file) {
$str = file_get_contents($path.$file);
$str = str_replace("\r\n", "jjjjjjjjjjjjjj", $str);
file_put_contents($path.$file);
}

How do I replace the null value

TIA

Nicolaas

This is what I did:

$nullcharacter= chr(0);
$str = str_replace($nullcharacter, "", $str);

OR

$str = str_replace("\0", "", $str);

HTH

Nicolaas

.