Skip to content

Instantly share code, notes, and snippets.

@hmkz
Created September 25, 2014 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hmkz/d842305ac02dd3f5e9a7 to your computer and use it in GitHub Desktop.
Save hmkz/d842305ac02dd3f5e9a7 to your computer and use it in GitHub Desktop.
転置インデックス実装例
//転置インデックスを作成
$comp_list_reverse = array();
foreach ($comp_list as $key => $value) {
$hashed = md5($value);
$comp_list_reverse[$hashed] = $key;
}
$keyword_name_list_reverse = array();
foreach ($keyword_name_list as $key => $value) {
$hashed = md5($value);
$keyword_name_list_reverse[$hashed] = $key;
}
foreach($list AS $data){
$hashed = md5($data['vc_kw']);
$comp_list_results = false;
$keyword_name_list_results = false;
if (isset($comp_list_reverse[$hashed])) {
$comp_list_key = $comp_list_reverse[$hashed];
$comp_list_results = isset($comp_list[$comp_list_key]);
}
if ($keyword_name_list_reverse[$hashed]) {
$keyword_name_list_key = $keyword_name_list_reverse[$hashed];
$keyword_name_list_results = isset($keyword_name_list[$keyword_name_list_key]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment