我有一个客户端将发送的动态字符串,我想从中创建逗号分隔的标签:
$subject = "Warmly little in before cousin as sussex and an entire set Blessing it ladyship.";
print_r($tags = explode(" ", strtolower($subject)));
然而,我想删除一组特定的词(例如定冠词),但如果它在分解数组中,我想删除该词的键和值:
$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');
如果数组中的这些单词之一在$definite_article
数组中,则$tags
删除该单词的键和值,新数组将取出这些单词。我将使用这个数组来array_rand
从中选择一组随机的单词。我已经尝试了很多事情来达到我的结果,但到目前为止还没有。有人可以帮我解决这个问题吗?