You really need to help us to help you out. I don't think translating any of the code in the threads that you have made will actually help you out: we'd be handing you fish, instead of teaching you to fish for yourself as the saying goes.
Please define the context in which your code snippets are used and coming from for each thread as the things that you are posting a very generic and any PHP code that we provide might well be wrong for the context in which you need to use it. For example, the append function above could be for any number of different things in Python. In PHP do you want a direct translation or; one working on an array, a user-defined classes, XML-specific classes (SimpleXML, DOM?), etc.?
If you want to write PHP, learn PHP, I seggust www.tizag.com. No offense, but it is annoying having someone continually asking for a translated function when no effort has been shown on his part at all. Us translating it is really doing you a disservice because you are not learning any PHP, the code we give you may not even work since we don't know the context.