我有一个客户端将发送的动态字符串,我想从中创建逗号分隔的标签:
$subject = "Warmly little in before cousin as sussex and an entire set Blessing it ladyship.";
print_r($tags = explode(" ", strtolower($subject)));
Run Code Online (Sandbox Code Playgroud)
然而,我想删除一组特定的单词(例如定冠词),但是如果它在爆炸数组中,我想删除该单词的键和值:
$definite_articles = array('the','this','then','there','from','for','to','as','and','or','is','was','be','can','could','would','isn\'t','wasn\'t', 'until','should','give','has','have','are','some','it','in','if','so','of','on','at','an','who','what','when','where','why','we','been','maybe','further');
Run Code Online (Sandbox Code Playgroud)
如果$definite_article数组中的其中一个单词在数组中,则$tags删除该单词的键和值,新数组将取出这些单词.我将使用这个数组array_rand来从中选择一组随机的单词.我已经尝试了很多东西来实现我的结果,但到目前为止还没有.有人可以帮我找到解决方案吗?
我有一个使用该explode()函数构建的数组,但看到我如何使用随机/动态数据,我看到索引不断变化:
Array
(
[2] => Title: Warmly little before cousin sussex entire set Blessing it ladyship.
[3] => Snippet: Testing
[4] => Category: Member
[5] => Tags: little, before, entire
)
Run Code Online (Sandbox Code Playgroud)
我需要始终从0开始订购数组.我正在测试不同的数据,有时它从0开始,而其他测试则从不同的数字开始.我研究并从零开始遇到数组,但它似乎只适用于那个用户特定情况.我可以在这里看到用于构建阵列的代码:https: //stackoverflow.com/a/10484967/1183323
我怎样才能做到这一点?
我有这个simplexml脚本我用来发布从表单输入的数据.
$xml = simplexml_load_file("links.xml");
$sxe = new SimpleXMLElement($xml->asXML());
$person = $sxe->addChild("link");
$person->addChild("title", "Q: ".$x_title);
$person->addChild("url", "questions_layout.php#Question$id");
$sxe->asXML("links.xml");
Run Code Online (Sandbox Code Playgroud)
当它出现时,它看起来像这样:
<link><title>Alabama State</title><url>questions_layout.php#Question37</url></link><link><title>Michigan State</title><url>questions_layout.php#Question37</url></link></pages>
Run Code Online (Sandbox Code Playgroud)
但我试过找到了该方法的位置和这个问题,以及但是没有格式的XML正确的线路,他们应该像
<link>
<title></title>
<url></url>
</link>
Run Code Online (Sandbox Code Playgroud)
在第一个引用链接中我甚loadXML至改为load,因为loadXML期望一个字符串作为XML.有人可以帮我找到解决方案吗?