0
// Setup Query
$query = $this->db->query('SELECT * FROM here');

// Pull in the appropriate data for the model
$toolkitName = $this->toolkits_model->find_by('id', $id);

// Strip the commas from incoming array
$matchMeCommas = $toolkitName->toolkits_listitems; 
$matchMe = explode(',', $matchMeCommas);    

// Print ID for each item in toolkit parent list
foreach ($query->result_array() as $row) :
echo $row['id'];
endforeach;

// Match each item from toolkit list item
foreach ($matchMe as $row2) :
echo $row2;
endforeach;

私がやろうとしているのは、これら2つの配列の値を一致させ、親リスト項目の結果を出力することです。現在何が起こっているのかというと、ID(2、3、4、5、ect)に関連する「234567891011」の2つの文字列を取得します。

同様の値を照合し、その特定のIDの結果を取得したいことを追加する必要があります。したがって、値2と4が一致する場合は、DBからそれらの情報を取得して印刷します。

何か案は?ありがとう!

4

1 に答える 1

2

まだ正確にはわかりませんが、これで始めることができます。

foreach($query->result_array() as $row){
    if(in_array($row['id'], $matchMe)){
        //this is a match ... do something
    }
}

また

すべての一致の配列を作成できます。

//get the ids from the query
$ids = array();
foreach($query->result_array() as $row){
    $ids[] = $row['id'];
}

$matches = array_intersect($matchMe, $ids);
于 2013-01-29T21:09:45.763 に答える