药方识别 #25

Merged
pengda merged 1 commits from wpd_shibie2 into master 7 months ago
  1. 13
      model/mFormula.php

13
model/mFormula.php

@ -329,14 +329,18 @@ class mFormula extends mBase {
$num_map = $GLOBALS['num_list'];
$num_list = implode('', array_keys($num_map));
foreach ($herbString_arr as $herbString) {
$pattern = '/^(..)(.*?)([' . $num_list . ']+)([^(]*)?((.*?))?/u';
$pattern = '/^(.)(.*?)([' . $num_list . ']+)([^(]*)?((.*?))?/u';
preg_match($pattern, $herbString, $matches);
if ($matches) {
$herb_name = str_replace(array('(', ')'), '', trim($matches[1] . $matches[2]));
$herb_num = str_replace(array('(', ')'), '', trim($matches[3] . $matches[4]));
$herb_desc = isset($matches[5]) ? str_replace(array('(', ')'), '', trim($matches[4])) : "";
$herb_arr[] = array(
'herb_name' => trim($matches[1] . $matches[2]),
'herb_num' => trim($matches[3] . $matches[4]),
'herb_desc' => isset($matches[5]) ? str_replace(array('(', ')'), '', trim($matches[5])) : "",
'herb_name' => $herb_name,
'herb_num' => $herb_num,
'herb_desc' => $herb_desc,
);
} else {
$herb_arr[] = array(
@ -345,7 +349,6 @@ class mFormula extends mBase {
'herb_desc' => "",
);
}
}
return $herb_arr;

Loading…
Cancel
Save