首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PHP仅从内容中提取id值

PHP仅从内容中提取id值
EN

Stack Overflow用户
提问于 2020-04-28 12:36:32
回答 1查看 41关注 0票数 0

我有一个内容

代码语言:javascript
复制
 through the pictures he captures, he expresses what he feels about a subject, be it a wedding shoot or couple’s portraits, by capturing emotions in its true essence. Pre-wedding shoots have unveiled to him numerous love stories in unimaginable ways. Every wedding is a different story yet with the same energy, colors and happy spirits all over. What he loves about all this is that he can help people beautify their memories and capture the best ones.</p>
<p><strong>Contact details:</strong></p>
<p>Mobile: +91 90496 80434<br>Email: <a href="mailto:ashishlangade@gmail.com">ashishlangade@gmail.com</a><br>Facebook page: <a href="https://www.facebook.com/AshishLangadePhotography">www.facebook.com/AshishLangadePhotography</a><br>Instagram page: <a href="https://www.instagram.com/3three.little.words/?hl=en">www.instagram.com/3three.little.words</a></p>
<p>&nbsp;</p>
<!-- wp:imagely/nextgen-gallery -->
  [ngg src="galleries" ids="568" display="basic_thumbnail"]
  <!-- /wp:imagely/nextgen-gallery -->

从该内容中,我只需要值568。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-28 12:42:31

您可以使用domdocument解析html。或者你可以用正则表达式提取它。

代码语言:javascript
复制
preg_match ( '/ids="(\d+)"/', $subject $aOut);
var_dump($aOut);

正如kerbholz所说,除非您将这些数据作为字符串使用并试图解析它,否则您应该已经拥有了id。

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61480333

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档