Bulls and Cows

leetcode.com/problems/bulls-and-cows/#.Xe2cloXJwuc.link

Runtime: 8 ms, faster than 100.00% of PHP online submissions for Bulls and Cows.
Memory Usage: 15 MB, less than 100.00% of PHP online submissions for Bulls and Cows.

class Solution {

    /**
     * @param String $secret
     * @param String $guess
     * @return String
     */
    function getHint($secret, $guess) {
        $A = 0;
        for($i = 0; $i < strlen($secret); $i++){
            if($secret[$i] == $guess[$i]){
                $A++;
                $secret[$i] = "A";
                $guess[$i] = "X";
            }
        }
        $B = 0;
        for($i = 0; $i < strlen($secret); $i++){
            if(strpos($secret, $guess[$i]) !== false){
                $B++;
                $secret[strpos($secret, $guess[$i])] = "B";
            }
        }
        return $A."A".$B."B";
    }
}