所以,我創建了一個陣列,通過手動添加的每個條目:我想一個沒有在PHP中預先定義數組
$Sections[] = "A.1.4.1";//900 0 900 0 900 900 888 800 800 913 900 900 900
$Sections[] = "A.1.4.2.1";// 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 994 976 954 900 846 779 516 430 344 328 239 150
$Sections[] = "A.1.4.2.2";//900 900 900 900 900 900 900 900 900 900 850 800 750 700 650 600 550 500 376 356 336 227
$Sections[] = "A.1.4.2.3";//1000 1000 1000 1000 900 900 1000 1000 1000 1000 893 803 763 492 516 491 336 336 240 24
$Sections[] = "A.1.4.3";//1000 1000 879 588 560 366 192 867 807 665
$Sections[] = "A.1.4.4";//1000 1000 1000 1000 994 864 620 456 1000 1000 1000
$Sections[] = "A.1.5.1";//900 0 900 800 464
$Sections[] = "A.1.5.2";//a 1000 1000 846 240
$Sections[] = "A.1.5.2";//b 900 900 700 356
$Sections[] = "A.1.5.3";//1000 879 192
$Sections[] = "A.1.5.4";//1012 922 456
//EU_A
$Sections[] = "A.2.5.1";//a 1048 1048 1048 1048 1004 800 576 378
$Sections[] = "A.2.5.1";//b 1048 1048 1048 1048 1004 820 592 384
$Sections[] = "A.2.5.2";//a 1048 1048 964 828 672 504 340
$Sections[] = "A.2.5.2";//b 1048 1048 972 836 696 536 376
$Sections[] = "A.2.5.3";//a 1048 1048 1048 1048 1004 800 576 378
$Sections[] = "A.2.5.3";//b 944 944 944 944 944 820 592 384
$Sections[] = "A.2.5.3";//c 1048 1048 1048 1048 1004 820 592 384
$Sections[] = "A.2.5.4";//a 1048 1048 1048 910 776 560 308
$Sections[] = "A.2.5.4";//b 944 944 944 928 804 588 348
$Sections[] = "A.2.5.4";//c 1048 1048 1048 928 804 588 348
$Sections[] = "A.2.7.1";// 560 504 424 304 240 200
$Sections[] = "A.2.7.2";// 520 448 416 360 312 280
//EU_B
$Sections[] = "B.2.4.1";
$Sections[] = "B.2.4.1";
$Sections[] = "B.2.4.2";
$Sections[] = "B.2.4.2";
$Sections[] = "B.3.4.1";
$Sections[] = "B.3.4.1";
$Sections[] = "B.3.4.2";
$Sections[] = "B.3.4.2";
//TR-114
$Sections[] = "A.2.1";
$Sections[] = "A.2.2";
(您可以隨意忽略的意見,這是名副其實的截斷並從我的代碼粘貼)
我的問題是,當我做
return $Sections;
,然後嘗試引用任何索引,我得到一個錯誤,它未初始化。
但是,如果我這樣做
$return[] = $Sections;
return $return;
我能夠輕鬆地引用索引。
我已經完全閱讀了數組的文檔,但我不明白爲什麼它會這樣做。我知道它的工作原理,我只想知道爲什麼。
我只能假設當$ Sections數組傳遞給$ return數組時,索引以某種方式「刷新」或「更新」。
編輯:我忘了提及這是在一個函數內部,它返回內部創建的數組。我敢肯定,每個人都會掌握了相當快,與return語句是什麼,所有
請按照索引顯示您嘗試訪問數組的位置的代碼。 –
你可能只是使用了錯誤的返回。你可以告訴我們代碼_using_函數並記下它發生的錯誤和行嗎? – Wrikken
您可以發佈產生錯誤的函數之外的代碼嗎? – Mike