$NoteKey = ",";
(loop) if ... then{
$NoteKey .= "</td><td>";
$NoteKey .= $val2;
$NoteKey .= "</td><td>";
$NoteKey .= $val3;
$NoteKey .= "</td><td>";
$NoteKey .= "</td></tr>";
$NoteKey .= ",";
}
$NoteKey_trim = trim($NoteKey, ",");
$NoteKey_clean = explode(",",$NoteKey_trim);
$NoteKey_unique = array_unique($NoteKey_clean);
问题在于没有输出......直到$NoteKey_clean
然后没有输出......
答案 0 :(得分:0)
$NoteKey_trim = trim($NoteKey, ",");// delete ","
$NoteKey_clean = explode(",",$NoteKey_trim); // $NoteKey_trim don't have ","
//explode can't find ","
$NoteKey_unique = array_unique($NoteKey_clean);
$NoteKey_trim = trim($NoteKey);
if(strpos(",",$NoteKey_trim)!==false){ // $NoteKey_trim has ","
$NoteKey_clean = explode(",",$NoteKey_trim);
$NoteKey_unique = array_unique($NoteKey_clean);
}
答案 1 :(得分:0)
String[] functions= commaSeperatedString.split(",");
List<String> uniqueFunctions = new ArrayList<>();
for (String function : functions) {
if ( !uniqueFunctions.contains(function.trim())) {
uniqueFunctions.add(function.trim());
}
}
return String.join(",",uniqueFunctions);