But think not that this famous town has
only harpooneers, cannibals, and
bumpkins to show her visitors. Not at
all. Still New Bedford is a queer place.
Had it not been for us whalemen, that
tract of land would this day perhaps
have been in as howling condition as the
coast of Labrador.
Justified text:
But think not that this famous town has
only harpooneers, cannibals, and
bumpkins to show her visitors. Not at
all. Still New Bedford is a queer place.
Had it not been for us whalemen, that
tract of land would this day perhaps
have been in as howling condition as the
coast of Labrador.
CODE FOLLOWS
<?php // Include the header file include('includes/header.php'); ?>
<!DOCTYPE html> <html lang="en"> <head> <title>Justifying Lines of Text</title> <link rel="stylesheet" type="text/css" href="common.css" /> </head> <body> <h1>Justifying Lines of Text</h1>
<?php
// The text to justify
$myText = <<<END_TEXT But think not that this famous town has only harpooneers, cannibals, and bumpkins to show her visitors. Not at all. Still New Bedford is a queer place. Had it not been for us whalemen, that tract of land would this day perhaps have been in as howling condition as the coast of Labrador.
END_TEXT;
$myText = str_replace( "\r\n", "\n", $myText );
$lineLength = 40; // The desired line length $myTextJustified = ""; $numLines = substr_count( $myText, "\n" ); $startOfLine = 0;