public static function toStackString($ex)
    {
        $stack = [];
        $i = 0;
        $trace = static::toStackTrace($ex);
        $pad = strlen(count($trace)) > 2 ?: 2;

        foreach ($trace as $element)
        {
            $stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
            ++$i;
        }

        return implode("\n", $stack);
    }
public static function toStackString($ex)
    {
        $stack = [];
        $i = 0;
        $trace = static::toStackTrace($ex);
        $pad = strlen(count($trace)) > 2 ?: 2;

        foreach ($trace as $element)
        {
            $stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element;
            ++$i;
        }

        return implode("\n", $stack);
    }
public static function toStackString ( $ ex ) { $ stack = [ ] ; $ i = 0 ; $ trace = static :: toStackTrace ( $ ex ) ; $ pad = strlen ( count ( $ trace ) ) > 2 ? : 2 ; foreach ( $ trace as $ element ) { $ stack [ ] = "\t" . str_pad ( '' . $ i , $ pad , ' ' , STR_PAD_LEFT ) . '. ' . $ element ; ++ $ i ; } return implode ( "\n" , $ stack ) ; }
Return Exception stack trace in string format.

@param \Error|\Exception $ex
@return string
Return Exception stack trace in string format .