I am a php programmer trying to understand python's for in syntax I get the basic for in
for i in range(0,5):
in php would be
for ($i = 0; $i < 5; $i++){
but what does this do
for x, y in z:
and what would be the translation to php?
This is the full code i am translating to php:
def preProcess(self):
""" plan for the arrangement of the tile groups """
tier = 0
tileGroupNumber = 0
numberOfTiles = 0
for width, height in self._v_scaleInfo:
#cycle through columns, then rows
row, column = (0,0)
ul_x, ul_y, lr_x, lr_y = (0,0,0,0) #final crop coordinates
while not ((lr_x == width) and (lr_y == height)):
tileFileName = self.getTileFileName(tier, column, row)
tileContainerName = self.getNewTileContainerName(tileGroupNumber=tileGroupNumber)
if numberOfTiles ==0:
self.createTileContainer(tileContainerName=tileContainerName)
elif (numberOfTiles % self.tileSize) == 0:
tileGroupNumber += 1
tileContainerName = self.getNewTileContainerName(tileGroupNumber=tileGroupNumber)
self.createTileContainer(tileContainerName=tileContainerName)
self._v_tileGroupMappings[tileFileName] = tileContainerName
numberOfTiles += 1
# for the next tile, set lower right cropping point
if (ul_x + self.tileSize) < width:
lr_x = ul_x + self.tileSize
else:
lr_x = width
if (ul_y + self.tileSize) < height:
lr_y = ul_y + self.tileSize
else:
lr_y = height
# for the next tile, set upper left cropping point
if (lr_x == width):
ul_x=0
ul_y = lr_y
column = 0
row += 1
else:
ul_x = lr_x
column += 1
tier += 1