BatCountry
11-09-2007, 05:53 AM
I'm opening up a few text files and insert the contents into a few arrays, and then merging them together - but I'm having difficulty in trying to append some text to the array, here's what I have so far:
<?
$list1 = file('1.txt');
$list2 = file('2.txt');
$list3 = file('3.txt');
$list4 = file('4.txt');
$full=array_merge_recursive($list1,$list2,$list3,$list4);
shuffle($full);
?>
Basically I read the files into the array, then combine them all, and shuffle up the order. But what I want to do is add some text to each so that I can later on figure out which text file each item came from.
What I want is something like this:
<?
$list1 = file('1.txt');
//append some text to say it came from file 1.txt
for (pseudo code){
$list1=$list1 . '###1.txt';
loop}
?>
Of course my actual for loop code doesn't work, because it timesout because it takes too much time to go through each item and append the text. I'm hoping there's a php function that allows you to append text without having to go through each item and append the text.
<?
$list1 = file('1.txt');
$list2 = file('2.txt');
$list3 = file('3.txt');
$list4 = file('4.txt');
$full=array_merge_recursive($list1,$list2,$list3,$list4);
shuffle($full);
?>
Basically I read the files into the array, then combine them all, and shuffle up the order. But what I want to do is add some text to each so that I can later on figure out which text file each item came from.
What I want is something like this:
<?
$list1 = file('1.txt');
//append some text to say it came from file 1.txt
for (pseudo code){
$list1=$list1 . '###1.txt';
loop}
?>
Of course my actual for loop code doesn't work, because it timesout because it takes too much time to go through each item and append the text. I'm hoping there's a php function that allows you to append text without having to go through each item and append the text.