从数组中检索重复的单词 [英] Retrieve repetitive words from an array

查看:61
本文介绍了从数组中检索重复的单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在给定的数组中得到所有重复的单词,似乎没有工作任何帮助将不胜感激。这是我的代码。



我尝试了什么:



i am trying to get all repetitive words in the given array and it seems not to be working any assistance will be appreciated. here's my code.

What I have tried:

<pre>

<!DOCTYPE html>
<html>
<head>
<title>Assignment</title>
</head>
<body>
	<?php 
function findrepetition($param){
	$str = array("Felix","Kingsley","Ishmael");
	for ($i=0; $i < count($str); $i++)
	{
		if(strstr($str, $param) === $str[$i])
		{
			echo "There is a repetition of the word ". $param . " in the string. ";
		};
	};
findrepetition("Felix");
?>
</body>
</html>
<?php } ?>

推荐答案

param){
param){


str = array( Felix Kingsley Ishmael);
for
str = array("Felix","Kingsley","Ishmael"); for (


i = 0;
i=0;


这篇关于从数组中检索重复的单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆