It gives me this error Notice: Undefined variable: newfile and of course it also gives me fwrite() expects parameter 1 to be resource, null given cause of the first error. What I doing wrong?
$file = fopen("mycsv.csv", 'r');
$newfile = fopen("myjson.txt", 'w');
function write($text, $tab) {
$tabs = "";
for ($index = 0; $index < $tab; $index++) {
$tabs .= "\t";
}
fwrite($newfile, $text."\n".$tabs); //error here
}