请教一个数组问题
var_export得到$var=mysql_fetch_array(mysql_query($sql))的结果:
array (
0 => 'a',
)
array (
0 => 'b',
)
array (
0 => 'c',
)
如果用in_array函数和某个字段$c匹配,不成功则echo N.
这个表达式要如何表达?
------解决方案--------------------
$arr = array ( 0 => array ( 0 => 'question three', 'detail' => 'question three', ), 1 => array ( 0 => 'question four', 'detail' => 'question four', ), 2 => array ( 0 => 'question five', 'detail' => 'question five', ), );$test = array(0 => 'question three', 'detail' => 'question three',);if (in_array($test,$arr)){ echo 'yes';}<br><font color="#e78608">------解决方案--------------------</font><br>foreach($var as $key=>$val){<br> foreach($val as $k=>$v){<br> if(in_array('c',$v)){<br> echo "C";<br> }else{<br> echo "N";<br> }<br> }<br><br>}<br>不知道你的具体是什么样的数组,这样应该可以,你可以试试。<div class="clear"> </div>