I am pulling data from a database that list the Language a person
  speaks and the id number. It is in a format like this.
  
 user_id        field_value
 6            English||Spanish
 2            English
 8            English||Portuguese||Finnish
 5            English||Japanese||German
 3            English
 1            English
 9            German

 each time it looks at a new record it list all the languages that that
 person speaks with a double pipe in between each language.

 What I need to do is find all the unique languages so I can generate a
 list of languages that do not have any repeats in it with each users
 id number that speaks that language. so the
 list above
 would be
 6,2,8,5,3,1 English
 8 Portuguese
 8 Finnish
 5 Japanese
 5,9 German
 6 Spanish

 Using the script below (I am using ADODB for a database layer) I am
 able to pull the data into an array of both fields so it gives me an
 array that looks like this
 Array ( [6] => English||Portuguese||Finnish [2] => English||Portuguese||German [8] => 
English [7] => English )  )

 But I can not figure out how to split it up so there is a list like I
 have above.
 I know I need to use explode, array_merge and array_unique but I am
 not sure how to set it up so it will work correctly
 
 $sql = "SELECT * FROM default_UserDBElements WHERE field_name = 'Languages'";
  $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; 
  $recordSet = $conn->Execute($sql); 
if (!$recordSet)
print $conn->ErrorMsg();
else
while (!$recordSet->EOF) {
$array[$recordSet->fields['user_id']] = $recordSet->fields['field_value'];
$recordSet->MoveNext();
}

print_r($array);

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to