0
我目前具有帶建立了基於斷一組動態服務器傳遞給它\優先級的陣列的腳本的問題與單個陣列中的鐵血\多維數組。例如,基於關閉輸入下面內創建它
server1,200
server2,200
我想建立的東西,看起來像
[email protected]() #at this point I have an empty array
[email protected]("server1",200) #at this point, I would expect to have an array
#that itself holds another array
但是在這一點上,當我運行此我得到意想不到的輸出
echo $arr.count # result is 2, rather than the 1 I would expect
# It appears to be treating $arr as a single array
# with two members (server1 and 200) rather than an array
# that holds an array, which itself has two members
但是,如果我添加另一個空陣列到我的陣列:
$arr = @()
$arr += @()
$arr += $("server1",200)
$arr.count # output is 2, which is the desired result
我得到了我想要的結果。我的問題是..我可以得到我想要的結果鋸齒\ multidimensional陣列只有一個單一的數組裏面呢?這不會是一個常見的情況,因爲大多數時候我會處理多組項目,但是我想說明所有情況,這可能會彈出一個。我只想不必爲了滿足這一點而添加一個額外的步驟來過濾出一個空數組。
任何輸入將不勝感激。