请问一个数组有关问题

WBOY
Release: 2016-06-13 13:52:13
Original
748 people have browsed it

请教一个数组问题
var_export得到$var=mysql_fetch_array(mysql_query($sql))的结果:
array (
  0 => 'a',
)
array (
  0 => 'b',
)
array (
  0 => 'c',
)

如果用in_array函数和某个字段$c匹配,不成功则echo N.

这个表达式要如何表达?







------解决方案--------------------

PHP code

$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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!