<?php

function r(){
    $n=rand(65,91);
    // if $n == 91, then $n-91 returns 0 (e.g. false), then we use 32 (e.g. ord(' '))
    // if $n != 91, then $n-91 returns not 0 (e.g. true), so we use $n
    return chr($n-91?$n:32);
}

function s($s){
    $c=0;
    $t='METHINKS IT IS LIKE A WEASEL';
    // The snippet "$s[$i]==$t[$i++]" returns true/false if $s[$i] == $t[$i]
    //   and has the side effect of incrementing $i
    // $c++ is the same as $c+=TRUE
    for($i=0;$i<28;$c+=$s[$i]==$t[$i++]);
    return $c;
}

for ($n = 65; $n <= 91; $n++) { var_dump(chr($n-91?$n:20)); }
var_dump( s('ZZZZZZZZ IT IS LIKE A WEASEL') );

?>