脚本宝典收集整理的这篇文章主要介绍了通过PHP为搜索创建索引,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我的第一个unsuccessful attempt如下.
#1
$result = pg_query_params ( $dbconn,"SELECT question_id,body From questions",array () ); while ( $row = pg_fetch_array ( $result ) ) { $question_body [ $row['question_id'] ] ['body'] = $row['body']; $question_index = explode ( " ",$question_body[ $row['question_id'] ] ['body'] ); $question_index = array_unique ( $question_index ); } var_dump( $question_index );
这段代码的问题在于它结合了每个问题中的单词.
似乎我不能使用爆炸,因为它似乎只制作一个单维数组.
我还运行以下代码试图获取question_id unsuccessfully.
#2
while ( $row = pg_fetch_array ( $result ) ) { $question_body [ $row['question_id'] ] ['body'] = $row['body']; $question_index[ $row['question_id'] ] = explode ( " ",$question_body[ $row['question_id'] ] ['body'] ); $question_index[ $row['question_id'] ]= array_unique ( $question_index ); } VAR_dump( $question_index );
以上是脚本宝典为你收集整理的通过PHP为搜索创建索引全部内容,希望文章能够帮你解决通过PHP为搜索创建索引所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。