[PHP] Merging Arrays

2001-09-21 Thread Jordan Elver

Hi,
I've got to different files of words. One on each line.
What would be the best way to combine both into one file alphabetically?
I thought about:

$file1 = file('file1.txt');
$file2 = file('file2.txt');
$both = array_merge($file1, $file2);

print_r($both);

Any advice?

Cheers,

Jord
-- 
Jordan Elver
Web Developer
The InternetOne UK Ltd

-- 
PHP General 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]




RE: [PHP] Merging Arrays

2001-09-21 Thread Boget, Chris

 I've got to different files of words. One on each line.
 What would be the best way to combine both into one file 
 alphabetically?

after you merge the arrays, use asort();

Chris



[PHP] merging arrays quickly

2001-08-17 Thread Michael

say I have
$array1 = array(name=NULL,thread=NULL,id=NULL);
$array2 = array(0=fred,1=3,2=);

I want $array1 to have the values of array2 - or $array2 to hve the keys
of $array1
A foreach loop works fine to do this - but I was wondering if there is a
quicker way to merge the values of one array to another array.

-- 
PHP General 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]




Re: [PHP] merging arrays quickly

2001-08-17 Thread Reuben D Budiardja

Take a look at the function array_merge
http://www.php.net/array_merge

Reuben D. B

On Friday 17 August 2001 08:46 am, you wrote:
 say I have
 $array1 = array(name=NULL,thread=NULL,id=NULL);
 $array2 = array(0=fred,1=3,2=);

 I want $array1 to have the values of array2 - or $array2 to hve the keys
 of $array1
 A foreach loop works fine to do this - but I was wondering if there is a
 quicker way to merge the values of one array to another array.


--
PHP General 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]




Re: [PHP] merging arrays quickly

2001-08-17 Thread Michael

Reuben D Budiardja wrote:
 
 Take a look at the function array_merge
 http://www.php.net/array_merge
 
 Reuben D. B
 

I have - it's no use unfortuntely  - The array with the values has
numeric keys so they just get appended - would have been okay if they
had string keys though.


 On Friday 17 August 2001 08:46 am, you wrote:
  say I have
  $array1 = array(name=NULL,thread=NULL,id=NULL);
  $array2 = array(0=fred,1=3,2=);
 
  I want $array1 to have the values of array2 - or $array2 to hve the keys
  of $array1
  A foreach loop works fine to do this - but I was wondering if there is a
  quicker way to merge the values of one array to another array.

-- 
PHP General 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]