From 9b19134ad9836ea79074a8ccf0d35fcfd1305a12 Mon Sep 17 00:00:00 2001 From: pengda <10266652509@qq.com> Date: Fri, 18 Oct 2024 14:12:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8D=AF=E6=96=B9=E8=AF=86=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- model/mFormula.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/model/mFormula.php b/model/mFormula.php index b7d7e6e..fb570c6 100644 --- a/model/mFormula.php +++ b/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;