如何使用大写字母打印数组?

时间:2015-09-21 03:08:07

标签: php

嘿大家我目前正在尝试完成我在代码学院的课程但是我被卡住了。我的任务是制作一个小游戏,从我的数组元素中随机选择一个包含朋友名字的胜利者。

我把它全部工作但我需要用大写字母打印出来。我怎样才能做到这一点?代码会是什么样子。这是我现在的代码:

    <?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>"









?>

1 个答案:

答案 0 :(得分:3)

如何做 strtoupper 呢?

<?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>';
?>

我认为这会做你想做的事。