- json_decode: documentation ( source)
<?php
$response_return = '';
$response = '{"status":"failure","reason":{"base":["Reached campaign cap"]},"testing":false}';
// Provide
$data = json_decode($response, true);
if ($data['status'] != 'failure') {
$response_return = 'Success';
} else {
foreach($data['reason']['base'] as $value)
$response_return .= $value.'\n';
}
echo($response_return);