Readmore function

Views: 9 Last modified: August 03rd, 2011 Comments: 0

This function returns a division named “excerpt”, along with a substring from the input text and url dynamically created!

Minimal 2 args: URL and TEXT;

function Readmore($url, $text, $length = 5)
{
    if (func_num_args() < 2)
        return 'Url and input text must be provided @ function: '. __FUNCTION__;
    // Create division
    $excerpt = "<div id=\"excerpt\">\n";
    // Get substring
    $excerpt .= substr(strip_tags($text), 0, $length)."\n<br /><br />";
    // Set url
    $excerpt .= "<a href=\"$url\">Read More</a>\n";
    // Close division
    $excerpt .= "</div>";

    return $excerpt;
}

echo Readmore('http://domain', $text);
VN:F [1.9.13_1145]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.13_1145]
Rating: 0 (from 0 votes)
    Bluehost

    Mail this!

    To: From:Sum {2+9} =  
    Anything to add ?

        You must be logged in to post a comment.