在PHP字符串操作,它是可以操縱的字符串像我們想,例如:陣列中的Java
$temp2 = array();
$theindex = 0;
foreach($arraysimpanloop as $a) {
$temp1 = array();
for($i = 0; $i < sizeof($a)-1; $i++) {
$temp1[$i] = $a[$i];
}
natsort($temp1); // sort array temp1
$stringimplode = implode($temp1);
$temp2[$theindex] = $stringimplode;
$theindex++;
}
由於我使用的是現在,Java,所以我不知道怎麼行:
$temp2[$theindex] = $stringimplode;
用Java代碼編寫。因爲我在java中試過:
temp2[theindex]= stImplode; // here temp2 is array of string
它總是返回一個空指針。
你有沒有初始化數組第一?就我個人而言,我懷疑該行拋出一個NullPointerException。你能展示你的Java代碼和堆棧跟蹤嗎? – Stultuske 2015-02-09 07:52:00
基於你在這裏向我們展示的一行代碼:'temp2 [theindex] = stImplode;' - 我們無法幫到你。如果您希望我們幫助您獲得NPE,請發佈您的代碼。 – alfasin 2015-02-09 07:54:02
請添加'java'代碼。 – Jens 2015-02-09 07:54:27