ASP怎么删除一维数组中的某个数值

数组:
1,5,8,12,355,23
比如想删除355这个数,应该怎么做呢?

不一定要删啊,你从数据库读出以后
例如:
假设当前数组为
Farray=split("2,5,6,8,11,13",",")
从Farray中取出13
randomX=Farray(6)
然后Farray(6)=-1
同理:
randomX=Farray(n)
Farray(n)=-1
需要再加个判断不然-1就被取出来了,呵呵
if Farray(n)>0 then
randomX=Farray(n)
Farray(n)=-1
end if

int[] copy;
int[] arr=[1,5,8,12,355,23];
foreach(var d in arr){
if d==355 continue;
copy.add(d);

}

新建一个数组,用循环将旧数组拷贝到新数组,遇到要删除的数时,越过去

 function removeItem(arr,v)
  dim arrl,finditem:finditem=-1
  arrl=ubound(arr)
  for i=0 to arrl
    if finditem=-1 and arr(i)=v then finditem=i    
    if finditem<>-1 and i<arrl then arr(i)=arr(i+1)
  next
  if finditem<>-1 then ReDim Preserve arr(arrl-1)'找到则删除最后一项
  removeItem=arr
end function

arr=split("1,5,8,12,355,23",",")
msgbox join(arr,",")
arr=removeItem(arr,"8")
msgbox join(arr,",")
arr=removeItem(arr,"355")
msgbox join(arr,",")

遍历在删除就可以了呀

找到索引index 直接removeat(index)应该可以吧

<%
'一个删除数组内元素的函数
Function moveR(farray,sarray)
a = Split(farray, ",")
Set dic = CreateObject("Scripting.Dictionary")
For k=0 To UBound(a)
If a(k)<> "" Then dic.Add "_" & a(k), a(k)
Next
a = Split(sarray, ",")
For k=0 To UBound(a)
If a(k)<> "" Then
If dic.Exists("_" & a(k)) Then
dic.Remove "_" & a(k)
End If
End If
Next
items = dic.Items()
Set dic = Nothing
moveR=Join(items, ",")
End Function
n1 = "a,b,1,11,12,13,14,15,16,17,19,20,22"
n2 = "a,1,12,14,18,19,20"
response.write mover(n1,n2)
'用法
n1 = "a,b,1,11,12,13,14,15,16,17,19,20,22"
n2 = "a,1"
response.write mover(n1,n2)
'结果是b,11,12,13,14,15,16,17,19,20,22
%>

遍历原有的数组,判断如果符合你要删除的那个就跳过,其他的元素从新拼装一个新的数组

遍历数组的时候直接跳过去这个数