Home  >  Article  >  Backend Development  >  数组比对有关问题

数组比对有关问题

WBOY
WBOYOriginal
2016-06-13 12:04:251088browse

数组比对问题

本帖最后由 u012984377 于 2014-08-08 11:21:42 编辑
实现string '越野,城市SUB' (length=16)
与数组里的'wjc_title' => string '2厢小轿车' (length=13)比对,看是否有满足条件的,

怎么搞,刚学习PHP不久
------解决方案--------------------
不要贴图,贴出你的数组。
说明一下满足条件是指什么? 
------解决方案--------------------
$ar1 = array('a1', 'a2');<br />$ar2 = array(<br />  array('wjc_id' =>'12', 'wjc_title' =>'a1'),<br />  array('wjc_id' =>'23', 'wjc_title' =>'sfdsds'),<br />);<br /> <br />function foo($item){<br />  global $value;<br />  return $value == $item['wjc_title'];<br />}<br />foreach($ar1 as $value){<br />  echo $value, ' ', array_filter($ar2, 'foo') ? '在' : '不在', PHP_EOL;<br />}
a1 在
a2 不在
Statement:
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