[SOLVED] Substr question
Posted: Tue Jul 13, 2004 10:40 am
Hi All,
Quick question, has anyone every had substr do anything wierd on them? I have been using it in a loop to cut entered data into chunks. The problem is the second time around on the loop grabs far more of the string than I tell it. (I get 180 chars even though I specify 160!)
I ended up putting another line in :$msgs[$i] = substr($msgs[$i],0,160); just to get it the right length, which seems wrong to me!
If any one has any offers I appreciate it!
RedRasper
Quick question, has anyone every had substr do anything wierd on them? I have been using it in a loop to cut entered data into chunks. The problem is the second time around on the loop grabs far more of the string than I tell it. (I get 180 chars even though I specify 160!)
Code: Select all
<?php
$msgs = array();
$messagestart = 0;
$messageend = 160;
for($i=0;$i<$msgnum;$i++) {
$msgs[$i] = substr($message,$messagestart,$messageend);
$messagestart +=160;
$messageend += 160;
}
?>If any one has any offers I appreciate it!
RedRasper