article site help remaining text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Naeem
Forum Commoner
Posts: 31
Joined: Tue Jul 07, 2009 12:48 pm

article site help remaining text

Post by Naeem »

Hi all hope you will be fine
I am creating a article site in this site i want to put some text on main page and link it via "read more" text from articles page and complete article will be present on article file/page how to do that.
dhenick
Forum Newbie
Posts: 19
Joined: Tue Oct 20, 2009 10:46 am
Location: Yogyakarta, Indonesia
Contact:

Re: article site help remaining text

Post by dhenick »

may be this function can help you.

Code: Select all

 
function putusHubungan($sumber,$jumlah){
    if(strlen($sumber) >= $jumlah){
        $putusanAwal = substr($sumber,0,$jumlah);
        $cariSpasiTerdekat = strpos($sumber," ",$jumlah);
        $putusanAkhir = substr($sumber,0,$cariSpasiTerdekat)." ....</div>";
    }else {
        $putusanAkhir = $sumber;
    }
    return $putusanAkhir;
}
$sumber = source of your article.
$jumlah = how many character will be show on that page
 
Jus call that function like this

Code: Select all

 
$source = "This is long description of article, i will cut this description.",
echo putusHubungan($source,10);
And the out put is like this
This is long description .....
 
you can visit my blog for detail at http://dhenick.web.id/?p=7 :mrgreen:
Post Reply