RE: modify array data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
I am wanting to rotate the array  45 degrees.

"Richard Lynch" <ceo@xxxxxxxxx> wrote in message
news:4409.24.148.18.109.1114201432.squirrel@xxxxxxxxxxxxxxxx
> 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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux