PHP Add Border
function addBorder($picture) {
    array_unshift($picture,str_repeat("*",strlen($picture[0])));
    foreach($picture as $k=> $v) {
        $picture[$k] = "*{$v}*";
    }
    $picture[] = str_repeat("*", strlen($picture[0]));
    return $picture;

}

This builds a new grid with a * border around every side. It adds a full top and bottom row, then wraps each existing row from left and right.