Jump to content

[SOLVED] How To Write Id On CSV File


refiking

Recommended Posts

Here's what that returned:

 

Call to undefined function: file_put_contents()

 

Here's the script used:

<?php
$file = file("file.csv");
for($i = 0;$i < count($file); $i++){
    $file[$i] = ($i+1) . "," . $file[$i];
}
if(file_put_contents("file.csv",implode("\r\n",$file))){
Echo 'Successful';
}
ELSE{
Echo 'Uh Oh!';
}
?>

try

<?php
$file = file("file.csv");
for($i = 0;$i < count($file); $i++){
    $file[$i] = ($i+1) . "," . $file[$i];
}
//
if($fh = fopen("file.csv","w")){
    fwrite($fh,implode("\r\n",$file));
    echo 'Successful';
    fclose($fh);
}else{
    echo 'Uh Oh!';
}
?>

 

Scott.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.