I have a PHP array called $json that I decoded from my .txt file. It has information laid out like this:
I'm trying to send the [email] and [fullname] to my database using PHP. I'm confused how to actually add the $json array to my code. I've been successful in adding the sample data but when replacing the add(array(
my code breaks. Can anyone give me a tip on how to pursue further?
$url = 'http://www.mywebsite.com/form/test.txt';
$content = file_get_contents($url);
$json = json_decode($content,true);
str_replace(array('[', ']'), '', htmlspecialchars(json_decode($json), ENT_NOQUOTES));
$auth = array(
'api_key' => 'xxxxxxxxxxxxx');
$wrap = new CS_REST_Subscribers('xxxxxxxxx', $auth);
$result = $wrap->add(array(
'EmailAddress' => "thisisatest@gmail.com",
'Name' => "john",
'CustomFields' => array(
array(
'Key' => 'Field 1 Key',
'Value' => 'Field Value'
),
array(
'Key' => 'Field 2 Key',
'Value' => 'Field Value'
),
array(
'Key' => 'Multi Option Field 1',
'Value' => 'Option 1'
),
array(
'Key' => 'Multi Option Field 1',
'Value' => 'Option 2'
)
),
'Resubscribe' => true
));