Jump to content

Printing an array using an index?


mattjtayl

Recommended Posts

Ok I have to print an ACH file from an array I will recieve.

 

I recieve this array through a function then I have to print this array to a file called "ACH.txt".

 

The ACH file is broken down like this.

 

position 01-017 is 1st record to be printed

 

position 018-30 is 2nd record to be printed

 

position 31-44 is 3rd record to be printed

 

etc.

 

 

I was thinking psuedo code like this

 

get_ACH_array = function () {

 

$ACH_Record = recieved array

 

$ACH_Record = array();

 

$a = position 17   

$b = positon 30   

$c = position 44

 

or I would define variables like this

 

$a = 17

$b = $a+13

$c= $b +14

 

create "ACH.txt"

 

$file = "ACH.txt"

$handle = fopen("ACH.txt", "w");

 

for ($i = 0; $i <$a, $i++){

fwrite $ACH_Record(i)

}

 

for ($i = 0; $i <$b, $i++){

fwrite $ACH_Record(i)

}

for ($i = 0; $i <$c, $i++){

fwrite $ACH_Record(i)

}

 

fclose($handle);

}

 

 

is this all right? is there a more effective way to do this? I know using actual numbers for indexing isn't a good thing

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.