作者 lyh

gx

... ... @@ -435,14 +435,12 @@ function isEnglish($str) {
* @method :post
* @time :2023/6/28 17:39
*/
function characterTruncation($string,$startTag,$endTag){
$startPos = strpos($string, $startTag);
$endPos = strpos($string, $endTag);
if ($startPos !== false && $endPos !== false) {
$startPos += strlen($startTag);
$result = substr($string, $startPos, $endPos - $startPos);
function characterTruncation($string,$pattern){
preg_match($pattern, $string, $matches);
if (isset($matches[1])) {
$result = $matches[1];
return $result; // 输出:这是footer标签的内容
} else {
echo "无法找到起始或结束标签";
return "未找到匹配的footer标签";
}
return $result;
}
... ...
... ... @@ -106,12 +106,12 @@ class BTemplateLogic extends BaseLogic
]
);
//字符串截取
$this->param['head_html'] = characterTruncation($this->param['html'],'<header>','</header>');
$this->param['main_html'] = characterTruncation($this->param['html'],'<main>','</main>');
$this->param['footer_html'] = characterTruncation($this->param['html'],'<footer>','</footer>');
$this->param['head_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-header">','</style>');
$this->param['main_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-style">','</style>');
$this->param['footer_css'] = characterTruncation($this->param['html'],'<style id="vvvebjs-footer">','</style>');
$this->param['head_html'] = characterTruncation($this->param['html'], '/<header[^>]*>(.*?)<\/header>/');
$this->param['main_html'] = characterTruncation($this->param['html'], '/<main[^>]*>(.*?)<\/main>/');
$this->param['footer_html'] = characterTruncation($this->param['html'], '/<footer[^>]*>(.*?)<\/footer>/');
$this->param['head_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-header">(.*?)<\/style>/');
$this->param['main_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-style">(.*?)<\/style>/');
$this->param['footer_css'] = characterTruncation($this->param['html'],'/<style id="vvvebjs-footer">(.*?)<\/style>/');
if($info === false){
$this->param['project_id'] = $this->user['project_id'];
$rs = $this->model->add($this->param);
... ...