The next time I stare at something so long I can't think straight remind
me to take a walk and pull out Rasmus' book! Page 121 array_chunk is my
friend!
Code is ugly, but I am smiling now! Thank you everyone!
$policy = array_slice ($fields, 18, $lineCount);
// I am taking the array from position 18 to the end
$chunks = array_chunk ($policy, 34);
// Using array_chunk I break the array into pieces of 34
foreach ($chunks as $key => $value){
print_r($chunks);
sleep(5);
}
// The sleep is for me to watch it fly by the screen :)
Thanks again everyone.
-Scott
-----Original Message-----
From: Scott [mailto:[EMAIL PROTECTED]]
Sent: Sunday, June 02, 2002 4:57 PM
To: 'Mark Heintz PHP Mailing Lists'
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP] Re: Parsing file's
Ok, this did not work, but I have a new idea. From the top....
1)Read in the csv file, take the first 18 records and insert them into a
temp db. Ie: $output = array_slice ($fields, 0, 17);
2)Then do a count on the line to see how many records are after 17 and
somehow loop through them 34 at a time.
It is easy if there is only one set, but I am not sure how to take the
remaining elements in the array and break them out 34 at a time until I
reach the end of the line.
Help, my head hurts and I have a habit of over thinking :)
-Scott
-----Original Message-----
From: Mark Heintz PHP Mailing Lists [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 31, 2002 4:43 PM
To: Scott
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: Parsing file's
You may have been heading in the right direction originally with
array_slice... This is off the top of my head, I don't guaruntee it
will
work...
$start = 34;
$interval = 15;
$max = 303;
// hop across orig. array 15 columns at a time
for($offset = $start;
$offset < $max && isset($array[$offset]);
$offset += $interval){
// slice off $interval many columns starting at $offset
$sub_array = array_slice($array, $i, $interval);
// handle your $interval many key-value pairs
foreach ($sub_array as $key => $value){
$policyWriter = "$quoteKey|$key|$value";
// ...
}
}
mh.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php