我有两个叮咬:
$var_x = "Depending structure";
$var_y = “Depending on the structure of your array ";
Run Code Online (Sandbox Code Playgroud)
你能告诉我怎样才能找到var_y中var_x中有多少单词?为了做到这一点,我做了以下事情:
$pieces1 = explode(" ", $var_x);
$pieces2 = explode(" ", $var_y);
$result=array_intersect($pieces1, $pieces2);
//Print result here?
Run Code Online (Sandbox Code Playgroud)
但是这并没有显示var_y中有多少var_x字
我有一个数组联系下面的话
(“hello”, “apple”, “hello”, “hello”, “apple”, “orange”, “cake”)
Run Code Online (Sandbox Code Playgroud)
Result here should be 5
你能否告诉我是否有一个库函数PHP,我可以用来计算我的数组中有多少重复的单词?任何帮助将不胜感激.
我是php的新手并试图使用map数组.我希望我$arr2能掌握不同类型水果的价值.但是,当我执行以下代码时,它告诉我"apple"是一个未定义的索引.您能否告诉我如何更正以下代码以便我可以访问不同的值?
<?php
main_fun ();
function main_fun ()
{
$arr2 = array();
num2_data ($arr2);
echo "<br>.".$arr2["apple"]["q1"]; // quadrant 1 value of apple
echo "<br>.".$arr2["orange"]["q2"]; // quadrant 2 value of orange
}
function num2_data (&$arr2)
{
$arr2 = array("apple" => array("q1" => 1.1380711874577, "q2" => 1.7625118400083, "q3" => 1.8957417329238, "q4" => 2.4453545524829));
$arr2 = array("orange" => array("q1" => 1.1380711874577, "q2" => 2.5045795667914, "q3" => 1.8957417329238, "q4" => 2.7192512120757));
}
?>
Run Code Online (Sandbox Code Playgroud) 我有一个wordpress页面.在该WordPress页面中,用户可以访问以下窗口,将Publish其发布到网页中.

如果用户在我上面用红色标记的三个字段中的任何一个中输入了URL,我的php代码将查看这些URL并确定它们是否是垃圾邮件.因此,我想把我的PHP代码放在Publish按钮中,所以我可以在我的php代码运行后禁止或允许发布,并确定这些URL是否是垃圾邮件.你可以告诉我我应该编辑的wordpress文件的名称,以便将我的PHP代码放入.我是wordpress的新手,并且不太了解他们的文件结构.
我有一个字符串如下:
is newegg.com a scam ? – fraudwatchers
当我将该字符串放入数组时,使用以下代码:
$title_word = str_word_count(“is newegg.com a scam ? – fraudwatchers”, 1);
Run Code Online (Sandbox Code Playgroud)
它给了我以下结果:
0 => string 'is' (length=2)
1 => string 'newegg' (length=6)
2 => string 'com' (length=3)
3 => string 'a' (length=1)
4 => string 'scam' (length=4)
5 => string '-' (length=1)
6 => string 'fraudwatchers' (length=13)
Run Code Online (Sandbox Code Playgroud)
我想要一个数组元素来包含整个世界“newegg.com”和另一个数组元素包含“?”你能告诉我如何用一个例子做到这一点.任何帮助将不胜感激.
更新:如果我使用explode(' ', $my_text);这不能正常工作.如果我要通过一个网页的主体,它会用一个新的行为一个数组元素分配几个单词.(我的阵列中也不需要任何单词).