Search code examples
right-align

How to right align several lines of text in PHP - newbie


I'm trying to right align a date and 6 lines of text on a letterhead using PHP, but either break the PHP code or it isn't right aligning all the text lines. This is the existing PHP code I've adjusted to this point which right aligns the date and the first two lines, but the rest of the text lines are still on the left. The end result I want to achieve is to align the date and the 6 lines of text after the date on the right side of the page.

<?php 
echo "<br />";
echo "<br />";
echo "<div align='right'>";
echo date("d/m/Y") . "</div><br />";
echo "<br />";
echo "<br />";
$user_info = wp_get_current_user(1);
echo "<div align='right'>";
echo $user_info->first_name .  " " . $user_info->last_name . "\n";
echo "Job Title</div>" . "\n";
echo 'Email: ' . $user_info->user_email. "\n";
echo 'Mobile: ' . $user_info->mobile_number. "\n";
echo 'Web Address: ' . $user_info->webaddress1. "\n";
echo 'Facebook Page: ' . $user_info->facebook. "\n";
echo "<br />";
echo "<br />";
echo "<hr />";
echo "Dear "  . $_POST["c_name"] . "," . "\n";

I'm very new at this so thanks so much for any help and suggestions.


Solution

  • change your code at line 9 from echo "<div align='right'>"; to echo "<div style='text-align:right'>";