foreach ($directions_array as $key => $direction) {
    if ($direction == "^") {
        // Up
        move_or_regift($current_house->x, $current_house->y + 1);
    } else {
        if ($direction == "v") {
            // Down
            move_or_regift($current_house->x, $current_house->y - 1);
        } else {
            if ($direction == "<") {
                // Left
                move_or_regift($current_house->x - 1, $current_house->y);
            } else {
                if ($direction == ">") {
                    // Right
                    move_or_regift($current_house->x + 1, $current_house->y);
                }
            }
        }
    }
}
class House
{
    public $x = 0;
    public $y = 0;
    public $gifts = 0;
    function __construct($x, $y, $gifts = 1)
    {
        $this->x = $x;
        $this->y = $y;
        $this->gifts = $gifts;
    }
    if ($direction == "^") {
        // Up
        move_or_regift($current_house->x, $current_house->y + 1, $person);
    } else {
        if ($direction == "v") {
            // Down
            move_or_regift($current_house->x, $current_house->y - 1, $person);
        } else {
            if ($direction == "<") {
                // Left
                move_or_regift($current_house->x - 1, $current_house->y, $person);
            } else {
                if ($direction == ">") {
                    // Right
                    move_or_regift($current_house->x + 1, $current_house->y, $person);
                }
            }
        }
    }
}
class House
{
    public $x = 0;
    public $y = 0;
    public $gifts = 0;
    function __construct($x, $y, $gifts = 1)
    {
        $this->x = $x;
        $this->y = $y;
        $this->gifts = $gifts;