Re: [PHP] modify array data

2005-04-26 Thread Jon Aston
I am wanting to rotate the array  45 degrees.


Richard Lynch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Fri, April 22, 2005 8:46 am, Jon Aston said:
  Is there a way to easily rotate array data?
 
  what I want to do is
  change from
 
  bob | bill | frank
  joe | jose | sam
  sally | jim | kim
 
  to
  |  | | frank||  |
  |  |bill | | sam|  |
  |bob| | jose  |   | kim|
  |  |joe| |jim   |  |
  |  | | sally || |
 
  is there an easy way to do this?
  the data and arraysize will vary so I was looking for a way that I could
  have php do it without having to make script for different array sizes.

 http://php.net/array

 Look at array_pop and array_push and count and array_slice and
 array_splice and array_shift.

 I really don't understand your BEFORE/AFTER diagrams at all, since it
 pretty much looks random to me...  In which case you want
 http://php.net/shuffle

 -- 
 Like Music?
 http://l-i-e.com/artists.htm

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



RE: [PHP] modify array data

2005-04-26 Thread Jay Blanchard
[snip]
I am wanting to rotate the array  45 degrees.

Richard Lynch [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Fri, April 22, 2005 8:46 am, Jon Aston said:
  Is there a way to easily rotate array data?
 
  what I want to do is
  change from
 
  bob | bill | frank
  joe | jose | sam
  sally | jim | kim
 
  to
  |  | | frank||  |
  |  |bill | | sam|  |
  |bob| | jose  |   | kim|
  |  |joe| |jim   |  |
  |  | | sally || |
 
  is there an easy way to do this?
[/snip]

To rotate an array 45 degrees (to the left) would be a difficult thing.
You could write a script that could do it and it would not matter your
array size. Consider the following as a thought experiment...

How many rows in the array? Is the number even or odd?
How many columns in the array? Is the number even or odd?
Does the number of rows match the number of columns?

Take the number of rows and divide in half. 
If the number is not an integer round it up to get the mid row.
If the number is an integer, add 1 to get a mid row. 
Take data in (0,0) and place in (0, mid row#) of new array
Take data in (0,1) and place it in (1, mid row#-1) of new array
And so on

Can it be done? Yes, it can. Is it going to take a while to figure
out.yes, it will. Good luck and let us know your results!

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



Re: [PHP] modify array data

2005-04-23 Thread Richard Lynch
On Fri, April 22, 2005 8:46 am, Jon Aston said:
 Is there a way to easily rotate array data?

 what I want to do is
 change from

 bob | bill | frank
 joe | jose | sam
 sally | jim | kim

 to
 |  | | frank||  |
 |  |bill | | sam|  |
 |bob| | jose  |   | kim|
 |  |joe| |jim   |  |
 |  | | sally || |

 is there an easy way to do this?
 the data and arraysize will vary so I was looking for a way that I could
 have php do it without having to make script for different array sizes.

http://php.net/array

Look at array_pop and array_push and count and array_slice and
array_splice and array_shift.

I really don't understand your BEFORE/AFTER diagrams at all, since it
pretty much looks random to me...  In which case you want
http://php.net/shuffle

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] modify array data

2005-04-22 Thread Jon Aston
Is there a way to easily rotate array data?

what I want to do is
change from

bob | bill | frank
joe | jose | sam
sally | jim | kim

to
|  | | frank||  |
|  |bill | | sam|  |
|bob| | jose  |   | kim|
|  |joe| |jim   |  |
|  | | sally || |

is there an easy way to do this?
the data and arraysize will vary so I was looking for a way that I could
have php do it without having to make script for different array sizes.

Thanks

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



Re: [PHP] modify array data

2005-04-22 Thread Brent Baisley
Well, it's just a matter of coming up with the formula for converting 
your data. I briefly tried to come up with one, but gave up after I 
realized there would not be a center data piece if you have a 4x4 
array or any even number array for that matter.
I would right down the array positions for before and after and try to 
find the pattern you are looking for. It should be some combination or 
rows, columns and array size (addition, subtraction, multiplicaiton, 
division, absolute values, etc.). If you can't find the pattern, you 
can't write a generic conversion function and neither can PHP or 
anybody.

Your first row maps like this (row,col):
0,0 - 2,0
0,1 - 1,1
0,2 - 0,2
This formula would map the first row appropriately:
row = ColCount - ColNum
col = ColNum
It obviously fails for your second row, but it's just an example.
There is obviously a pattern which the mind can interpret fairly 
quickly. But trying to describe it in exact terms can be difficult.

On Apr 22, 2005, at 11:46 AM, Jon Aston wrote:
Is there a way to easily rotate array data?
what I want to do is
change from
bob | bill | frank
joe | jose | sam
sally | jim | kim
to
|  | | frank||  |
|  |bill | | sam|  |
|bob| | jose  |   | kim|
|  |joe| |jim   |  |
|  | | sally || |
is there an easy way to do this?
the data and arraysize will vary so I was looking for a way that I 
could
have php do it without having to make script for different array sizes.

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

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php