the array shows as this:
$_ADMINLANG['global']['jumppage'] = "Jump to Page";
$_ADMINLANG['global']['go'] = "Go";
$_ADMINLANG['months']['january'] = "January";
$_ADMINLANG['months']['february'] = "February";
.......
now, i want to output the above data as this:
$_ADMINLANG['global']['jumppage'] =
$_ADMINLANG['global']['go'] 开发者_运维百科=
$_ADMINLANG['months']['january'] =
"Jump to Page";
"Go";
"January";
how do i do ? thank you.
If you want to simply print the values as you mentioned, then this must be the code.
$temp = '';
foreach ($_ADMINLANG as $key1 => $arr) {
foreach ($arr as $key2 => $val) {
echo '$_ADMINLANG["'.$key1.'"]["'.$key2.'"] = <br />';
$temp .= $val.'<br/>';
}
}
echo $temp;
just loop through the array and echo the keys (first output) and for the second output echo the values.
have a look at the foreach function: http://php.net/manual/en/control-structures.foreach.php
http://www.php.net/manual/en/function.array-keys.php - returns keys of array
http://www.php.net/manual/en/function.array-values.php - returns values of array
I really don't know if this is just about outputting the array contents, but if it is, here you go:
$_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 />';
}
}
精彩评论