I'm trying to get all my first characters in a PHP array to be uppercase.
PHP code:
<?php $ordlista = file_get_contents('C:/wamp/www/bilder/filmlista.txt'); $ord = explode("\n", $ordlista); sort($ord,SORT_STRING); foreach ($ord as $key => $val) { echo $val."<br/>"; } ?>
To use a keyboard shortcut to change between lowercase, UPPERCASE, and Capitalize Each Word, select the text and press SHIFT + F3 until the case you want is applied.
To convert all array elements to uppercase:Use the map() method to iterate over the array. On each iteration, call the toUpperCase() method to convert the string to uppercase and return the result. The map method will return a new array with all strings converted to uppercase.
You can use str. title() to get a title cased version of the string. This converts the first character of each word in the string to uppercase and the remaining characters to lowercase.
$ord = array_map('ucfirst', $ord);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With