Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Make a new CSV File Through PHP Script.

    • 0
    • 1
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 222
    Comment on it

    This tutorial show's how to create a new CSV file through PHP script.
    This script is more helpful for php developer to create a new CSV file in array formate.

    1. function functionname (parameter)
    2. {
    3. if (($handle = fopen("$data", "r")) !== FALSE)
    4. {
    5. while (($csv_data = fgetcsv($handle, 1000, ",")) !== FALSE)
    6. {
    7. $categorydata[]=$csv_data;
    8. }
    9. }
    10. $categorynum=count($categorydata);
    11. $categorydata[$categorynum][1]=$new_cat_name;
    12. $categorydata[$categorynum][2]='1';
    13. $categorydata[$categorynum][3]='n';
    14. $categorydata[$categorynum][4]='0';
    15. $categorydata[$categorynum][5]=$overcategory;
    16. $filepointer = fopen($data, 'w') or error('ggg');
    17. foreach($categorydata as $updated_data)
    18. {
    19. fputcsv($filepointer,$updated_data);
    20. }
    21. fclose($filepointer);
    22. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: