<?php

$Ashraf = "Ashraf";
$str ="$Ashraf
";
rotateText($str);

function rotateText($str)
{
    $lines     = explode(PHP_EOL, $str);
    $lengths   = array_map('strlen', $lines);
    $maxLength = max($lengths);
    $lines     = array_map(function ($line) use ($maxLength) {
        return str_pad($line, $maxLength, ' ', STR_PAD_LEFT);
    }, $lines);
    $chars     = array_map('str_split', $lines);
    array_unshift($chars, null);
    $rotatedLines = call_user_func_array('array_map', $chars);
    $rotatedText  = join(PHP_EOL, array_map('join', $rotatedLines));
    return $rotatedText;
}

echo "<pre>", rotateText($str), "</pre>";

?>