PHP如何截取指定两个字符串之间的文字?

2025-05-14 07:31:05
推荐回答(4个)
回答1:

$str='

USB PC Joystick Game Controller

';
preg_match_all('/]*>(.*)<\/h1>/',$str,$match);
print_r($match[1][0]);

回答2:

游戏说明部分可以修改一下,比如说前面加个标签


改成:
if(preg_match('/
(.*)<\/div>/iU',trim(strip_tags($post->post_content,"
")),$result))

回答3:

if(preg_match('/游戏介绍:<\/strong><\/p>\s+

(.*)<\/p>/iU',trim($post->post_content),$result))

无需去掉P标签再匹配,去掉了反而取不到

回答4:

preg_match('/游戏介绍.*<\p>.*

(.*)<\/p>/isU',$body,$arr);
试下