我正在尝试让脚本搜索 $open_email_msg ,其中不同的电子邮件将具有不同的信息,但格式如下。我只想要他们在 Title: 或 Tags: 或 Categories: 之后放置的任何内容,而不是字符串“Title:”或“Tags:”或“Categories:”这只是整个代码的片段,其余的将信息插入到 MySQL 表中,然后发布到网站上的新闻文章中。
有人可以帮我找到解决方案吗?
严格的电子邮件格式:
新闻更新
标题:文章标题
标签:tag1 tag2
类别:文章类别,第 2 篇文章类别
片段:文章片段。
消息:文章消息。图片。更多文字,更多文字。Lorem impsum dolor 坐在一起。
<?php
//These functions searches the open e-mail for the the prefix defining strings.
//Need a function to search after the space after the strings because the subject, categories, snippet, tags and message are constant-changing.
$subject = strpos($open_email_msg, "Title:"); //Searches the open e-mail for the string "Title"
$categories = strpos($open_email_msg, "Categories:"); //Searches the open e-mail for the string "Categories"
$snippet = strpos($open_email_msg,"Snippet"); //Searches the open e-mail for the string "Snippet"
$content = strpos($open_email_msg, "Message"); //Searches the open-email for the string "Message"
$tags = str_replace(' ',',',$subject); //DDIE
$uri = str_replace(' ','-',$subject); //DDIE
$when = strtotime("now"); //date article was posted
?>