Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6390833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:35:49+00:00 2026-05-25T03:35:49+00:00

I am getting an error when posting via ajax to a csv file via

  • 0

I am getting an error when posting via ajax to a csv file via php.

<?php
$list = array ($_POST["array"]);
$fp = fopen('array.csv', 'w');
fputcsv($fp, $list);
fclose($fp);
?>

My array i am trying to post

["0", "0", "0", "0", "0", "0", "0", "0", 99]

The response:

Notice: Array to string conversion in C:\xampp\htdocs\snx\assets\www\write.php on line 4

My Ajax post;

/* Array */
var defaultArray = new Array();
var localArray = new Array();
var serverArray = new Array();

/* Default Values */
defaultArray[0] = "0";
defaultArray[1] = "0";
defaultArray[2] = "0";
defaultArray[3] = "0";
defaultArray[4] = "0";
defaultArray[5] = "0";
defaultArray[6] = "0";
defaultArray[7] = "0";
defaultArray.push(99);

/* Write Array [1st Load] */
$.post("write.php", { 'array': defaultArray });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T03:35:49+00:00Added an answer on May 25, 2026 at 3:35 am
    $list = array ($_POST["array"]);
    

    If $_POST['array'] is already an array, Array($_POST['array']) makes an array of [one] arrays of strings.

    If you write print_r($list), you will see something like this:

    Array(0 =>
     Array(
       0 => "0",
       1 => "0",
       2 => "0",
       3 => "0",
       4 => "0",
       5 => "0",
       6 => "0",
       7 => "0",
       8 => 99
     )
    )
    

    To use the original array of strings, you probably just want:

    $list = $_POST["array"];
    

    Now, when you write print_r($list), you’ll see the expected:

    Array(
       0 => "0",
       1 => "0",
       2 => "0",
       3 => "0",
       4 => "0",
       5 => "0",
       6 => "0",
       7 => "0",
       8 => 99
    )
    

    BTW, use only .push for adding items to Javascript arrays, which you should instantiate like = [], not = new Array().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm posting ckeditor content via Ajax to php. But getting 4-5 sentence of posted
i am posting to a mailer.php file. mailer.php <?php if(isset($_POST['submit'])) { $to = testabc@gmail.com;
I started getting this error when posting the form back with Model Binder. To
I am getting error trying to run my asp code for executing stored proc.
hi im new to c# and was trying to code but getting error can
When trying to compile GNU software on HP-UX (binutils for example) I'm getting error
I'm a newbie Rails developer who is getting the following error when trying to
js.I am trying to create a file upload using node.js and mongodb.I am getting
I keep getting the following error when trying to parse some html using BeautifulSoup:
I have recently started getting this error while posting to facebook newsfeed stream of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.