【问题标题】:How does one unset an array element in ASP classic?如何在 ASP 经典中取消设置数组元素?
【发布时间】:2013-04-22 13:53:32
【问题描述】:

是否有等效于 PHP unset(array1[3]) 函数的 ASP Classic?

【问题讨论】:

  • 这将有助于我们这些不懂 PHP 的人描述 unset 函数应该做什么。
  • 为什么要使用它?在 ASP 中,我们通常在数组拆分后使用不同的变量名,因此无需取消数组。
  • PHP 中的 Unset() 会破坏给定的变量/数组元素。就我而言,我需要删除数组中间的一个元素。

标签: arrays asp-classic unset


【解决方案1】:

我想这至少可以做到,对于一个数字数组:

sub unset(array, index)
   if index < lbound(array) or index > ubound(array) then exit sub

   dim i, move
   move = false
   for i = lbound(array) to ubound(array)
      if i = index then move = true

      if move and i < ubound(array) then
         array(i) = array(i + 1)
      end if
   next

   redim preserve array(i - 2)  
end sub

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-07
    • 2021-05-29
    • 2010-09-17
    • 2011-11-02
    • 1970-01-01
    • 1970-01-01
    • 2018-07-16
    • 2011-02-20
    相关资源
    最近更新 更多