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



Reply via email to