假设我有一个包含以下数据的数组:
@array[0] = "hello this is a text"
@array[1] = "this is a cat"
@array[2] = "this is a dog"
@array[3] = "this is a person"
@array[4] = "this is a computer"
@array[5] = "this is a code"
@array[6] = "this is an array"
@array[7] = "this is an element"
@array[8] = "this is a number"
我想要一个循环,它遍历所有数组元素,如果元素确实有狗,则找出其中是否有任何元素具有值“狗”,然后删除该元素。所以结果是:
@array[0] = "hello this is a text"
@array[1] = "this is a cat"
@array[2] = "this is a person"
@array[3] = "this is a computer"
@array[4] = "this is a code"
@array[5] = "this is an array"
@array[6] = "this is an element"
@array[7] = "this is a number"