[英]how i check the string 'patient' using in_array in php
我的数组是:
$com_arr = Array(
[0] => patient
[1] => novel
[2] => name
[3] => monkey
[4] => yourself
[5] => novel
[6] => buttons
[7] => fifth
[8] => stories
[9] => English
[10] => sign
[11] => children
)
和变量$values_for_ex[$r-1] = patient
和我的函数看起来像
if(in_array($values_for_ex[$r-1] ,$com_arr)) {
$replacements1 = "<span style='color:green;font-weight:700;' id='s'>"
. $values_for_ex[$r-1] . "</span>";
}
但条件不起作用..为什么?
这是更正后的代码。 出于测试目的,我假设$r
的值为 5。
$com_arr = array(
'patient',
'novel',
'name',
'monkey',
'yourself',
'novel',
'buttons',
'fifth',
'stories',
'English',
'sign',
'children'
);
$r=5;// hard-coded for testing purpose
$values_for_ex[$r-1] = "patient";
if(in_array($values_for_ex[$r-1] ,$com_arr)) {
$replacements1 = "<span style='color:green;font-weight:700;' id='s'>". $values_for_ex[$r-1] . "</span>";
echo $replacements1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.