How can you search only unique words with PHP Ben arama yaparken temellerini öğrenebilirsiniz böyle?
Ben sorular için çok boyutlu bir dizi yapımında birkaç sorun vardı.
Benim ilk unsuccessful attempt şudur.
#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 );
The problem with this code is that it combines the words in each question.
It seems that I cannot use explode
, since it seems to make only a single dimensional array.
Ben de unsuccessfully question_id almaya çalışırken aşağıdaki kodu çalıştırın.
#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 );