$line .= "type={$result['message']['type']}&"; unset($result['message']['type']); unset($result['message']['packet']); foreach ($result['message'] as $field => $value) { $line .= "{$field}={$value}&"; } print substr($line, 0, -1) . "\n"; break; case 'xml': $xml->push('syslog_message'); $xml->element('ip', $result['ip']); $xml->element('mac', $result['mac']); $xml->element('firmware', $result['firmware']); $xml->push('message'); foreach ($result['message'] as $field => $value) { if ($field == 'packet') { $xml->cdataElement($field, $value); } elseif ($field && $value) { $xml->element($field, $value); } } $xml->pop(); $xml->pop(); break; } } // finalise output if ('xml' == $format) { $xml->pop('messages'); print $xml->getXml(); }