06-23-2009, 10:27 AM
|
#1 (permalink)
|
|
The Wanderer
Join Date: Jun 2009
Posts: 20
Thanks: 2
|
PROBLEM IN writing code
dear all..
I wanted to write some code which is already in python..but as i m very new in php not able find which function like hasattr i have to use at that place.can anyone tell me how to write this code in php...
python code is..
def replaceWith(self, replaceWith):
#store old parent
oldParent = self.parent
#get own index in parents contents array
myIndex = self.parent.contents.index(self)
# if mine and replaceWith's parent is same
if hasattr(replaceWith, 'parent') and replaceWith.parent == self.parent:
# We're replacing this element with one of its siblings.
index = self.parent.contents.index(replaceWith)
if index and index < myIndex:
# Furthermore, it comes before this element. That
# means that when we extract it, the index of this
# element will change.
myIndex = myIndex - 1
|
|
|
|