title: Sending JSON Array via PHP (Campaign Monitor)
body: <p>I have a sample JSON Array labeled sample.txt that is sent from a sweepstakes form that captures a user's name and e-mail. I'm using WooBox so the JSON Array sends information over by each entry, so there are two entries here: <a href="http://pastebin.ca/3409546" rel="nofollow">http://pastebin.ca/3409546</a></p>
  
  <p>On a previous question, I was told to break the ][ so that JSON_ENCODE can figure the separate entries. I would like to capture just the name and e-mail and import the array to my e-mail database (campaign monitor). </p>
  
  <p>My question is: How do I add JSON variable labels to an array? If you see my code, I have tried to use the label $email. Is this the correct form or should it be email[0] with a for loop?</p>
  
  <pre><code> $url = 'http://www.mywebsite.com/sweeps/test.txt';
   $content = file_get_contents($url);
   $json = json_decode($content,true);
  
   $tmp = explode('][', $json_string);
   if (!count($tmp)) {
   $json = json_decode($json_string);
  
   var_dump($json);
   } else {
   foreach ($tmp as $json_part) {
      $json = json_decode('['.rtrim(ltrim($json_string, '['), ']').']');
  
      var_dump($json);
  }
  }
   require_once 'csrest_general.php';
   require_once 'csrest_subscribers.php';
  
   $auth = array(
   'api_key' =&gt; 'xxxxxxxxxxxxxxx');
   $wrap = new CS_REST_Subscribers('xxxxxxxxxx', $auth);
   $result = $wrap-&gt;add($json(
  'EmailAddress' =&gt; $email,
  'Name' =&gt; $custom_3_first,
  'Resubscribe' =&gt; false
   ));
  </code></pre>
  
  <p><a href="https://github.com/campaignmonitor/createsend-php/blob/master/samples/subscriber/add.php" rel="nofollow">https://github.com/campaignmonitor/createsend-php/blob/master/samples/subscriber/add.php</a></p>