简体   繁体   中英

How can I make my array print out in uppercase letters?

Hey everyone I'm currently trying to finish my course on code academy but i'm stuck. My task is to make a little game that randomly selects a winner from my array elements which contain names of friends.

I have it all working but I need it to print out in uppercase letters. How can I do this? What would the code look like. Here is the code i have now:

    <?php
$friends=array("Nando","Evan","Ron","Aleks");
array_push($friends,"Jacob","kyle");


sort($friends);

count($friends);

$winner=array_rand($friends,1);


print "<p>$friends[$winner]</p>"









?>

How about doing a strtoupper to do that?

<?php
$friends=array("Nando","Evan","Ron","Aleks");
array_push($friends,"Jacob","kyle");
sort($friends);
// you don't need it because you are not using it
// count($friends);

$winner=array_rand($friends,1);
print '<p>'.strtoupper($friends[$winner]).'</p>';
?>

I think that would do what you are trying to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM