Hi!

Does anyone know of a function in php that will take a chunk of text and seperate it 
into 'chunks' preferably returning it in an array?

The reason being is that I have some columns(oracle) that are set to varchar2(4000) 
and I have text that is 4000+ AND :-) I cannot change it to another format. 

I was unable to find a chunk maker so I built one.

function chunk_maker($text)
{
        // have to count the number of characters, if over 3500 characters need to 
split into chunks of 3500 characters
        $count = xcount($text);
        if($count > 3500)
        {
                $chunk_count = $count/3500;
                //need to clean up the $chunk_count by removing the trailing decimals 
and
                //adding one to the total to make sure we do not loose in characters
                $chunk_count = floor($chunk_count)+1;
                $i=0;
                $start=0;
                while($i != $chunk_count)
                {
                        // err well this helps to make sure we get the correct amount 
of characters
                        if($start == 0)
                        {
                                $final = 3500;
                        } else {
                                $final = 3499;
                        }

                        //now we need to make the chunks and stick them in an array

                        $text2[]=substr($text,$start,$final);

                        // err well this helps to make sure we get the correct amount 
of characters
                        if($start == 0)
                        {
                                $start=1;
                        }
                        $start=$start+3500;
                        $i++;
                }
        } else {
                $text2[] = $text;
        }
        return($text2);
}

function xcount($text)
{
        global $debug;
        foreach (count_chars($text) as $my_value) $length=$length+$my_value;
        tracker($length);
        return($length);
}


If I just failed to find the right functions please let me know, otherwise please 
help! :-)
 

Jimmy Brake


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to