Welcome Guest, Not a member yet? Register   Sign In
Dvide article for part.
#4

[eluser]xwero[/eluser]
using
Code:
function wordcount($str) {
return count(array_filter(explode(' ', $str)));
}
function wordlimiter($str,$start,$end){
$temp = array_filter(explode(' ', $str));
return array_slice($temp,$start,$end);
}
you could split up the article for instance in three parts
Code:
$words = wordcount($row->content);
$partwordsnr = floor($words/3);
$parts = array();
$start = 0;
$end = $partwordsnr;
for($i=0;$i<3;$i++)
{
   $parts[] = wordlimiter($row->content,$start,$end);
   $start = $partwordsnr;
   $end = $count+$partwordsnr;
}
Then in the view you could do something like
Code:
<div class="articlecontent">
&lt;?php foreach($parts as $part){ ?&gt;
<div class="articlepart">&lt;?php echo $part; ?&gt;</div>
&lt;?php } ?&gt;
</div>
It's ruff code but it might give you some idea on how you can accomplish what you want.

update : code mistake


Messages In This Thread
Dvide article for part. - by El Forum - 10-25-2007, 04:53 PM
Dvide article for part. - by El Forum - 10-25-2007, 05:16 PM
Dvide article for part. - by El Forum - 10-26-2007, 01:34 AM
Dvide article for part. - by El Forum - 10-26-2007, 05:16 AM
Dvide article for part. - by El Forum - 10-26-2007, 05:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB