I’m wondering if there is an easy way to create SplStack from an array. Sure I can write a simple function that will do that: However, I don’t like this approach, because I have to iterate over the array and push items one by one. Is there a way to create a stack directly from the array? Answer The documentation
Tag: spl
Spl, ArrayObject, ArrayObject::STD_PROP_LIST
I’m trying to understand STD_PROP_LIST constant in the documentation but so far i didn´t understand it, and didn´t found any explanation 🙁 The documentation has the following example: Both prints give me the same exact result: Anyone could help me understanding what is the difference between using this constant or not? Thanks in advance! Answer The ArrayObject and ArrayIterator are
Extending ArrayObject in PHP properly?
Problem: I am trying to extend PHP’s ArrayObject as shown below. Unfortunately I can’t get it to work properly when setting multi-dimensional objects and instead an error thrown as I have the strict settings enabled in PHP. (Error: Strict standards: Creating default object from empty value) Question: How can I modify my class to automatically create non-existing levels for me?