Re: [PHP] Changing order of just one array item?

2003-01-19 Thread Leif K-Brooks
Thanks, but that's not what I'm trying to do.  I know how to change the 
keys, but I'm looking to change the internal order of the key/value pairs.

Timothy Hitchens (HiTCHO) wrote:

This would do it:

?php

$first[] = 'hello';
$first[] = 'bye';

function swap($list, $first, $second)
{
	$tempOne = $list[$first];
	$list[$first] = $list[$second];
	$list[$second] = $tempOne;	
}

swap($first, 0, 1);

print_r($first);

?


Timothy Hitchens (HiTCHO)
Open Source Consulting
e-mail: [EMAIL PROTECTED]

 

-Original Message-
From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, 19 January 2003 12:36 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Changing order of just one array item?


I need to change where one item is ordered in an array.  I 
know how to 
sory an array, but I need to move one item up/down in the 
array.  Example: $array is: 0 = element one 1 = element 
two 2 = element three 3 = element four I call 
array_order_up($array[1]) and $array is now: 0 = element 
one 2 = element three 1 = element two 3 = element four

If there aren't any native functions to do this, can anyone 
think of a 
way to make my own function to do this?

--
The above message is encrypted with double rot13 encoding.  
Any unauthorized attempt to decrypt it will be prosecuted to 
the full extent of the law.



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

   



 


--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.





Re: [PHP] Changing order of just one array item?

2003-01-19 Thread -[ Rene Brehmer ]-
Hi Leif K-Brooks,

The key is but an alias to the value, so other than rewriting the array I
cannot see how to split the two apart.

I don't believe there's any simple way to reorder the key/value order of
an array  dunno, I'm not used at using key'ed arrays ... PHP is the
only language (I know) that's got it, and since I program in a couple
other languages that don't have it, I'd just get confused by starting to
use them.

Rene

On Sun, 19 Jan 2003 10:28:58 -0500, you wrote about Re: [PHP] Changing
order of just one array item? something that looked like this:

Thanks, but that's not what I'm trying to do.  I know how to change the 
keys, but I'm looking to change the internal order of the key/value pairs.

-- 
Rene Brehmer

This message was written on 100% recycled spam.

Come see! My brand new site is now online!
http://www.metalbunny.net

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Changing order of just one array item?

2003-01-18 Thread Timothy Hitchens \(HiTCHO\)
This would do it:

?php

$first[] = 'hello';
$first[] = 'bye';

function swap($list, $first, $second)
{
$tempOne = $list[$first];
$list[$first] = $list[$second];
$list[$second] = $tempOne;  
}

swap($first, 0, 1);

print_r($first);

?


Timothy Hitchens (HiTCHO)
Open Source Consulting
e-mail: [EMAIL PROTECTED]

 -Original Message-
 From: Leif K-Brooks [mailto:[EMAIL PROTECTED]] 
 Sent: Sunday, 19 January 2003 12:36 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Changing order of just one array item?
 
 
 I need to change where one item is ordered in an array.  I 
 know how to 
 sory an array, but I need to move one item up/down in the 
 array.  Example: $array is: 0 = element one 1 = element 
 two 2 = element three 3 = element four I call 
 array_order_up($array[1]) and $array is now: 0 = element 
 one 2 = element three 1 = element two 3 = element four
 
 If there aren't any native functions to do this, can anyone 
 think of a 
 way to make my own function to do this?
 
 -- 
 The above message is encrypted with double rot13 encoding.  
 Any unauthorized attempt to decrypt it will be prosecuted to 
 the full extent of the law.
 
 
 
 -- 
 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