<?php
$options = ['paper', 'rock', 'scissors'];
$lookup = array_flip($options);
$outcomes = ['draw', 'win', 'lose'];
// only extract a random value if the player has selected an option -- otherwise there is no comparison executed.
$cpuSelection = $options[array_rand($options)];
$playerSelection = 'rock';
$comparison = $lookup[$cpuSelection] - $lookup[$playerSelection];
var_export([
'cpu' => $cpuSelection,
'human' => $playerSelection,
'outcome' => $outcomes[($comparison + 3) % 3]
]);