-2

I'd like if there was a way to capitalize the first letter of each line using PHP.

<?php 
$text="namjaga da geureochi mwo narago dareugetni
cheoeumen da akkyeojwodo naragabeorigo maneun
namjaga da geureochi mwo narago teukbyeolhalkka
ni mameul da gajyeodo naragabeorigo maneun
namjaga da geureochi mwo"
?>

<p>
<?php echo $text; ?>
</p>

Thank you for your help !

  • 2
    You tried something like searching PHP manual OR stackoverflow ? – CS GO Oct 29 '14 at 16:01
  • I did many times, but everything was about capitalizing the first letter of each word or of a string. Yet, I had not thought about David's answer to this question – user2911849 Oct 29 '14 at 16:24

1 Answers1

0

You can try something like

$textParts = explode("\n", $text);
foreach ($textParts as $key => $value) {
   $textParts[$key] = ucfirst($value);
}

$text = implode("\n", $textParts);
David Ansermot
  • 6,052
  • 8
  • 47
  • 82