This article mainly introduces the web version of the rock-paper-scissors game implemented in PHP, involving PHP array traversal, comparison and random array calling related operation skills. Friends in need can refer to the following
The details are as follows:
"; $input = array($computer,$what); //将输入的what和电脑随机产生的值构造成一个数组,再判断在不在获胜规则中 if (!(in_array($what,$my_array))) { echo "请输入 剪刀、石头、布"; header("location:index.php"); } if ($computer == $what) { echo "噢,平手"; }elseif (in_array($input,$guize)) { echo "电脑胜"; }else { echo "你赢咯~"; } } ?>剪刀石头布
The operation effect diagram is as follows:
The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
Detailed explanation of regular expression examples in PHP
phpSummary of examples of common methods for reading XML_phpTips
##PHP implements decimal, binary, octal and hexadecimal Methods of converting related functions
#
The above is the detailed content of Web version of rock-paper-scissors game implemented in php. For more information, please follow other related articles on the PHP Chinese website!