3v4l.org

run code in 300+ PHP versions simultaneously
<?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;
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.26, 8.4.1 - 8.4.13
{ "space": "abc", "markdown": "**welcome**", "attachment": [ { "contentType": "application\/json", "content": { "type": "mytype", "body": [ { "type": "TextInfo", "text": "TEST TEXT", "wrap": true } ] } } ] }

preferences:
136.91 ms | 408 KiB | 5 Q