1

How to have text in Vertical in PHP ??

I need text to be displayed in vertical style in Table Td text

it should print vertical or i need it to rotate ?

PHPNewuser
  • 43
  • 2
  • 7
  • 11
  • 1
    What has php got to do with it? –  Aug 06 '10 at 19:52
  • 1
    You mean use PHP to render a graphic with vertical text? PHP doesn't handle text display, you'd need to use CSS like in [this question](http://stackoverflow.com/questions/1080792/how-to-draw-vertical-text-with-css-cross-browser) – Michael Mrozek Aug 06 '10 at 19:52
  • 1
    Do you just want the letters to appear above each other? Or do you also want the letters to be rotated by 90 (or 270) degrees? – Frerich Raabe Aug 06 '10 at 19:52
  • You give us very little to work with. Could you be more specific? What is your input? What do you want your result to be? One datacell? the text spread out over multiple datacells? – Scharrels Aug 06 '10 at 19:52
  • Please clarify your question. Generally text is styled with CSS, unless you're trying to generate an image made of text in PHP or something. What exactly are you trying to do? – Syntax Error Aug 06 '10 at 19:53
  • I want to have vertical text in table td , how to have it ? I want to display text in vertical text text should be in vertical style – PHPNewuser Aug 11 '10 at 20:01

3 Answers3

5

CSS:

For FF 3.5 or Safari/Webkit 3.1, check out: -moz-transform (and -webkit-transform). IE has a Matrix filter(v5.5+).

.rot-neg-90 {
  /* rotate -90 deg, not sure if a negative number is supported so I used 270 */
  -moz-transform: rotate(270deg);
  -moz-transform-origin: 50% 50%;
  -webkit-transform: rotate(270deg);
  -webkit-transform-origin: 50% 50%;
  /* IE support too convoluted for the time I've got on my hands... */
}

PHP: (Since OP had tagged PHP)

If you meant vertical text on an image however, try:

header ("Content-type: image/png"); 

// imagecreate (x width, y width)
$img_handle = @imagecreatetruecolor (15, 220) or die ("Cannot Create image"); 

// ImageColorAllocate (image, red, green, blue)
$back_color = ImageColorAllocate ($img_handle, 0, 0, 0); 
$txt_color = ImageColorAllocate ($img_handle, 255, 255, 255); 
ImageStringUp ($img_handle, 2, 1, 215, $_GET['text'], $txt_color); 
ImagePng ($img_handle); 
ImageDestroy($img_handle);
Sarfraz
  • 377,238
  • 77
  • 533
  • 578
4

That does not have anything to do with PHP.

Just use the proper CSS properties

http://www.w3.org/TR/2001/WD-css3-text-20010517/#PrimaryTextAdvanceDirection

EDIT: sorry, I thought this was cross-browser, but it looks like it only works in IE You can use -webkit-transform: rotate(-90deg); or -moz-transform: rotate(-90deg); for cross-browser compatibility.

nico
  • 50,859
  • 17
  • 87
  • 112
1

Assuming you want your output to be actual text, and not a graphic, you'll need to use CSS text rotation. Text rotation isn't currently part of the standard (though CSS3 should change that) and is generally supported by way of browser-specific prefixes (-webkit-transform for webkit, -moz-transform for Mozilla browsers) or text filters (IE).

This article provides a good overview on how to use CSS text rotation in a cross-browser way.

Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153