$arr = array(
'some ugly string as key' => 'value',
'some ugly string as key2' => 'value2',
);
I know it can be done with:
$arr['some ugly string as key'] = 'prefix' . $arr['some ugly string as key']
But is there shorter way to select the first element? Because the key string is quite long in my case…
(i just need to prepend some text to the first, and append some text to the last value)
I’d use array_keys() to get the keys themselves as an array, then pick the first, and last elements from that array using [0] and [length-1].