- json_decode: documentation ( source)
- json_encode: documentation ( source)
<?php
$attachment = '[{
"contentType": "application/json",
"content": {
"type": "mytype",
"body": [{
"type": "TextInfo",
"text": "TEST TEXT",
"wrap": true
}]
}
}]';
// Add attachment string (JSON data) in an array
$mydata = array(
'space' => "abc",
'markdown' => "**welcome**",
'attachment' => json_decode($attachment)
);
// Turn array into one big JSON string
$send_json = json_encode($mydata, JSON_PRETTY_PRINT);
echo $send_json;