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
https://forums.phpfreaks.com/topic/74718-printing-an-array-using-an-index/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.