title: Posting array using cURL in Terminal
body: <p>I'm trying to build a webservice for an app, so the data stores in an online database I have. I'm currently building the php document, and I'm curious as to how I can <code>POST</code> an <code>array</code> using <code>cURL</code> in the <strong>Terminal Mac app</strong>. </p>
  
  <p>You see, the application will send an array consisting of strings to the webservice. For example something like this <code>["String 1", "String 2", "String 3"]</code>. 
  But to test if the code I have for inserting these values into the database works, I need to pass this data to the webservice somehow. Up until now I've been using the <strong>Mac Terminal app</strong> and posted like this <code>curl -F "user_id=1" localhost/test/webservice.php"</code>, but I don't know how to pass an array. </p>
  
  <p>What I have so far is this:</p>
  
  <pre><code>curl -F "user_id=1" -F "title=Random title 123" -F "num_items=2" -F "items[]=[Item 1, Item 2]" localhost/test/webservice.php
  </code></pre>
  
  <p>But I don't think that's the correct way to pass an array, because I believe the code I have in my php document is correct, but the value that's stored in my database is literally the word <strong>array</strong>. I believe <code>items[]</code> is the correct way to start it, but I'm not so sure about what comes after the <code>=</code>-sign. </p>
  
  <p>Anyone know the correct way to do this?</p>
  
  <p>If this happens to be correct, then there's something wrong with how I store the data in my array. I'm using <code>stmt</code> and the <code>bind_param()</code> keyword like this:</p>
  
  <pre><code>$items = $_POST["items"]; // This is the array
  
  $stmt = $this-&gt;db-&gt;prepare('INSERT INTO items (item_id, user_id, title) VALUES (?, ?, ?)');
  $stmt-&gt;bind_param('iis', $item_id, $user_id, $items);
  $stmt-&gt;execute();
  $stmt-&gt;close();
  </code></pre>
  
  <p>What I'm trying to achieve is basically posting all the values fron the array into the database with one insert statement. If that's wrong, what is the correct way to do it?</p>
  
  <p>All help is appreciated!</p>
  
  <p>Thanks.</p>