I need some help with re-working the logic on this php code. What I'd like to do is build in some conditions in this foreach loop to handle empty values, null and give it some default value like 'n/a'. Its using the $class_array to match one of the cases which is read from a text file, but if I don't have either of the statuses, then make it 'n/a'.
I'm just not clear how to construct that. Here is part of the code. I'm thinking, it must be handled within this foreach condition?? Thanks.
$class_array = array(
'Process succeeded' => 'success',
'Process failed' => 'failure',
'Review Logs for status' => 'warn',
'Check for Errors' => 'warn'
);
foreach ($InputFile as $line){
preg_match_all("/([0-9])-([^=]+)=([^;]+);/", $line, $matches, PREG_SET_ORDER);
$LineData = array();
foreach ($matches as $information) {
$LineData[$information[2]] = $information[3];
}
$timestamp = strtotime($LineData["LogDate"]." ".$LineData["StartTime"]);
$LineData['StartTime'] = date("Y-m-d H:i:s",strtotime($LineData['StartTime']));
$LineData['server_url'] = $server_array[$LineData['Server']];
$LineData['status_class'] = $class_array[$LineData['Status']];
$data[$timestamp] = $LineData;
}