Don't ask to ask, just ask | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
A good way to approach a problem like this, and you don't know how, is to think how you would do it in real life and then tell the computer to to that exact same thing. So we need a simile here. You have, in front of you, a partly filled in crosswords puzzle. This is array 1. Your friend, whom you're on the phone with, has the exact same crosswords puzzle, but still entirely blank. This is array 2. What you and your friend want, is to solve this crossword puzzle over the phone but you want to be "on the same page", so the two of you have decided that you will give him all the answers you've already found. How would you do this? You would walk through your answers and using their numbers as a reference, you relay the words you've found. So what you would say would sound like this: "One horizontal is monkey. Two vertical is bisshop. Fourty-six horizontal is mountain." In other words, as you iterate over array 1, you keep track of the "position" you're at, and then use that to do the corresponding position in array 2 &mdash in this case, tell your friend to fill in the value you have at that position. Which is exactly what BrowserUk and blue_cowdawg are doing above, here and here. In reply to Re: Get same position value in 2nd array
by muba
|
|