Is it possible to do use strtoupper or other functions into implode ?
Something like that ?
$labelsString = implode(':', strtoupper($this->labels));
Or do I have to use foreach ?
答案 0 :(得分:2)
Array_map() helps you: it apply function to all array elements, then return result array, which you can pass to implode function:
$labelString = implode(':', array_map('strtoupper', $this->labels));
答案 1 :(得分:0)
implode needs array input string implode ( string $glue , array $pieces )
but string strtoupper ( string $string ) return string.
So you need to convert the output of strtoupper from string to array. Then you can pass it to implode.