Is it possible to edit a string like Text-element
to TextElement
? After each - it needs an capital letter.
I can't get it done and can't figure out a way to do this.
You could do:
$text = implode(array_map('ucfirst',explode('-',$str)));
First we split all string at point of hyphen -
and then each of the first letter would be in caps. Then, join it back.
This shoudl do it ...
$string = "Text-element";
$s = explode("-", $string);
$finished_string = $s[0] . ucfirst($s[1]);
$text = preg_replace_callback(
'/-([a-z])/',
function (array $match) { return strtoupper($match[1]); },
$text
);