区分文本中的文字与图片
有段文本如下,我想用php把其中的文字部分弄出来赋值给一个变量,图片描述的部分再区分出来赋值给一个变量,用程序怎么实现?
物品尺寸/规格:高24厘米,,好东西值得收藏。
700? 700: true);" title="1.jpg"/>
700? 700: true);" title="2.jpg"/>
700? 700: true);" title="3.jpg"/>
<br />$content=<<<TXT<br /><p>物品尺寸/规格:高24厘米,,好东西值得收藏。</p><p><img src="/ueditor/php/../../data/attachment/antique//20141123/14167157082579.jpg" style="max-width:90%"界别文本中的文字与图片" > 700? 700: true);" title="1.jpg"/></p><p><img src="/ueditor/php/../../data/attachment/antique//20141123/14167157109272.jpg" style="max-width:90%"界别文本中的文字与图片" > 700? 700: true);" title="2.jpg"/></p><p><img src="/ueditor/php/../../data/attachment/antique//20141123/14167157112075.jpg" style="max-width:90%"界别文本中的文字与图片" > 700? 700: true);" title="3.jpg"/></p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1863">
<img src="https://img.php.cn/upload/ai_manual/000/000/000/175680400564100.jpg" alt="Cleanup.pictures">
</a>
<div class="aritcle_card_info">
<a href="/ai/1863">Cleanup.pictures</a>
<p>智能移除图片中的物体、文本、污迹、人物或任何不想要的东西</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="Cleanup.pictures">
<span>53</span>
</div>
</div>
<a href="/ai/1863" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="Cleanup.pictures">
</a>
</div>
<br />TXT;<br /><br />$data = explode('</p><p>', $content);<br />$str1 = $data[0].'</p>';<br />unset($data[0]);<br />$str2 = '<p>'.implode('</p><p>', $data);<br /><br />echo $str1;<br />echo $str2';<br /><br />$s='<p>物品尺寸/规格:高24厘米,,好东西值得收藏。</p><p><img src="/ueditor/php/../../data/attachment/antique//20141123/14167157082579.jpg" style="max-width:90%"界别文本中的文字与图片" > 700? 700: true);" title="1.jpg"/></p><p><img src="/ueditor/php/../../data/attachment/antique//20141123/14167157109272.jpg" style="max-width:90%"界别文本中的文字与图片" > 700? 700: true);" title="2.jpg"/></p><p><img src="/ueditor/php/../../data/attachment/antique//20141123/14167157112075.jpg" style="max-width:90%"界别文本中的文字与图片" > 700? 700: true);" title="3.jpg"/></p>';<br />preg_match_all('/[\x7f-\xff]+/',$s,$a);<br />$s1=implode('',$a[0]);<br />preg_match_all('/title="(.*?)"/',$s,$b);<br />echo $s1; //文字部分<br />print_r($b[1]); //图片描述<br />
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号