string length

    Date: 02/20/07 (PHP Community)    Keywords: database

    yes i am back again, but this is a quick one, due to brain shutdown.

    I'm pulling article titles from the database to display on the index page with a "read more" link, but each article also has a "short description" to go with it. 'd like to display this short description, but limit how long it is. So that if it is longer than, say, 40 chars, to cut it off and add three dots (...) before displaying the 'read more' link.

    So, i know i can use $descLength = strlen($artDesc'] to find out how long it is. Then the start of the if would be if($descLength > 40), but it's the bit in the middle i'm stuck on .

    $descLength = strlen($artDesc'];

    if($descLength > 40) {

    $newDesc = 40 char long version of $descLength;
    $newDesc .= "...";

    }

    i just need that bit in the middle. Is it something like rtrim()?

    many thanks in advance!

    paul.

    Source: http://community.livejournal.com/php/543593.html

« Hosting recommendations? || PHP, MySQL LEFT JOINS etc »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home