예제 #1
0
 /**
  * Convenience method to parse each output line.
  *
  * @param array $array array containing well formated output.
  * @param[in] string $lines array containing line to be parsed.
  * @param int  $i counter to keep track of line to be parsed.
  *
  */
 private static function _parseEOL(&$array, &$lines, &$i)
 {
     //check for error in result (if line starts with E)
     if (preg_match("/^E/", $lines[$i])) {
         ++$i;
         return;
     }
     // begin of result line
     // increment counter by 4 to go to the result data
     if ($lines[$i] == 'W: ---------------------------') {
         // go to data
         $i += 5;
         return;
     }
     // end of result data
     // increment counter by 2 to go to the next result line
     if ($lines[$i] == 'W: ') {
         // go to next result data
         ++$i;
         return;
     }
     // process result line
     // 1- get field (last word in line)
     $split_array = explode(' ', $lines[$i]);
     $split_num = count($split_array);
     $field = $split_array[$split_num - 1];
     // add field to results array
     PACS::_addKey($array, $field);
     // 2- get value
     // value should be formated as follow
     // [VALUE]
     $tmpsplit = split('\\[', $lines[$i]);
     // we didn't find any "[": no value was provided
     if (count($tmpsplit) == 1) {
         $array[$field][] = 'nvp';
     } else {
         $value = split('\\]', $tmpsplit[1]);
         $array[$field][] = utf8_encode(trim($value[0]));
     }
     ++$i;
 }