Capitalize First word in PHP

user2246395 picture user2246395 · Apr 23, 2013 · Viewed 8.2k times · Source

As i am using PHP, So problem comes to me that how can i captilized the first Letter In this Code.

<?php foreach($aa as $row):?>

<?php echo ''.$row->username.'' ?>
<?php endforeach; ?>

Answer

MatthewMcGovern picture MatthewMcGovern · Apr 23, 2013

Php has a ucfirst() function it Make a string's first character uppercase.

<?php echo ''.ucfirst($row->username).'' ?>