gpt4 book ai didi

php - 如果在另一个数组中找到,则删除一个数组的元素

转载 作者:IT王子 更新时间:2023-10-29 00:51:56 26 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
Remove item from array if it exists in a 'disallowed words' array

我有一个客户端将发送的动态字符串,我想从中创建逗号分隔的标签:

$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 使用这个数组来从中随机选择一组单词。我已经尝试了很多事情来实现我的结果,但到目前为止还没有。有人可以帮我解决这个问题吗?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com