2011-08-04 52 views
0

陣列顯示爲這樣:分割出關鍵和價值?

$_ADMINLANG['global']['jumppage'] = "Jump to Page"; 
$_ADMINLANG['global']['go'] = "Go"; 
$_ADMINLANG['months']['january'] = "January"; 
$_ADMINLANG['months']['february'] = "February"; 
....... 

現在,我想輸出上面的數據,因爲這:

$_ADMINLANG['global']['jumppage'] = 
$_ADMINLANG['global']['go'] = 
$_ADMINLANG['months']['january'] = 
"Jump to Page"; 
"Go"; 
"January"; 

我該怎麼辦?謝謝。

+0

我有一個蛋糕。 \ * teh codez \ *。真的,我們需要**更多細節**;你想做什麼,你想從中得到什麼? – Bojangles

+0

不清楚你的問題是什麼。什麼是期望的輸出。你的代碼是什麼?怎麼樣:'echo「$ _ADMINLANG ['global'] ['jumppage'] =」。 '''。$ _ADMINLANG ['global'] ['jumppage']。''';'? –

+0

'echo $ _ADMINLANG ['global'] ['jumppage'];'??? – Yoshi

回答

0

如果您只想打印值如你所說,那麼這一定是代碼。

$temp = ''; 
foreach ($_ADMINLANG as $key1 => $arr) { 
    foreach ($arr as $key2 => $val) { 
     echo '$_ADMINLANG["'.$key1.'"]["'.$key2.'"] = <br />'; 
     $temp .= $val.'<br/>'; 
    } 
} 
echo $temp; 
+0

關鍵是「mergefields」,我想輸出這個'mergefields'。如何改變它? – zhuanzhou

+0

我改變了這個回聲「$ _ADMINLANG ['」。$ key1。「''['」。$ key2。「']」。 '
';。但IDE顯示錯誤 – zhuanzhou

+0

''$ _ADMINLANG ['「。$ key1。」'] ['「。$ key2。」''。「。
''必須正確 – Goysar

0

我真的不知道這是否只是輸出數組的值數組內容,但是如果是這樣,請點擊這裏:

$_ADMINLANG['global']['jumppage'] = "Jump to Page"; 
$_ADMINLANG['global']['go'] = "Go"; 
$_ADMINLANG['months']['january'] = "January"; 
$_ADMINLANG['months']['february'] = "February"; 

foreach ($_ADMINLANG as $sub) { 
    foreach ($sub as $key => $val) { 
     echo $val, '<br />'; 
    } 
} 
+0

但是沒有這樣的輸出:$ _ADMINLANG ['global'] ['go'] – zhuanzhou

+0

@zhuanzhou啊,你想字面上顯示數組的定義嗎?我可以問你需要什麼嗎?也許有更好的方法來做事情? – Yoshi