Hi All,
Very new to web design and PHP, but I seem to be learning along the way.
I am building a HGV Drivers website for a friend of mine for his business. On the homepage I have managed to echo text for my 'Latest News' section. I would like to be able to limit the text to say about 60 characters. Does anyone know how I would be able to do this? Need a simple speaking solution lol.

This is the php code for my Latest News Section;

   <?php do { ?>
      <div id="newsRepeatRegion">
        <div class="newsRepeatRegionHeadline"><?php echo $row_newsRS['news.headline']; ?></div>
        <div class="newsRepeatRegionNews"><?php echo $row_newsRS['new.description'];
?>
</div>
        <div class="newsRepeatRegionDate"><?php echo date("d F Y",strtotime($row_newsRS['news.date'])); ?></div>
  <div class="newsRepeatRegionLink"><a href="news.php?id=<?php echo $row_newsRS['id']; ?>">Read More</a></div>
      </div>
      <?php } while ($row_newsRS = mysql_fetch_assoc($newsRS)); ?>

Hope someone can help!

Cheers
Kieron

Hi,

The substr() function can be used to extract a portion of a string, with a specified length.
Here is an example:

$str = 'Here can be a long text, we keep only the first 25 characters';
$str = substr($str, 0, 25);
echo $str;         // Here can be a long text,

In your code will be:echo substr($row_newsRS['id'], 0, 60);
More details an examples with substr() you can find on php.net .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.