Reputation: 103
It is possible to change "keys" values in foreach PHP? For example I have database like this:
https://i.sstatic.net/Ep9sl.png
And I want to get this data, and display it in:
foreach ($array as $key => $value) {
...
}
How can I change the "keys" if i don't want do display, for example "u_group" but "Group"?
PS. Sorry for my bad english ^ ^"
Upvotes: 0
Views: 164
Reputation: 54831
Create some language array, where keys are $key
and value is proper text.
E.g:
$langs = ['u_group' => 'Group', 'u_other' => 'Other'];
foreach ($array as $key => $value) {
echo 'User ' . $langs[$key] . ': ' . $value;
}
Upvotes: 2