-1
我检查标签,如果它存在的标签应该存在但随后转到存在和不存在的条件,这是我的代码:传递函数变量
function _checkTagsExists($tag , $chimptags){
foreach($chimptags as $key => $value){
if($value == $tag){
$response[ 'value' ] = $value;
$response[ 'exists' ] = 1;
$response[ 'tag' ] = $tag;
$response[ 'interests_id' ] = $key;
}
}
return $response;
}
$actags = array('existingtag1','existingtag2');
$interests = array('key1'=>'existingtag1','key2'=>'existingtag2');
foreach($actags as $actag){
$tagscheck = _checkTagsExists($actag , $interests);
//if tag is already existing
if($tagscheck[ 'exists' ] == 1){
$message[] = "exists";
}else{
$message[] = "NOT exist";
}
}
var_dump($message);
该代码产生
array{0 => "exists", 1 => "NOT exist"}
但它应该是所有存在
你应该改写你的问题,因为它实际上很难理解。 –
我刚刚运行你的代码,它的工作原理:array(2){[0] => string(6)“exists”[1] => string(6)“exists”} – Neil
OMG是啊我也试过了,我需要更改代码,因为我只是使用简单的数组 – Andrei