Search code examples
phpfilefwritebackspace

PHP - backspace in file with fwrite


I can't put a backspace in a File I try with:

fwrite($file, "\tpublic static function byPk(");
foreach ($pk as $column)
    fwrite($file, "\$" . $column->name . ", ");
fwrite($file, "\x08");

But the result in the file is:

Any solution? Thanks! :D


Solution

  • A solution is to use fseek() to go backward. http://php.net/manual/fr/function.fseek.php

    You can also make an array with your columns names and implode them.