From c56ace6f2b24f91c7ddb7ec88537dd3d77b9634a Mon Sep 17 00:00:00 2001
From: Emiel Bruijntjes
- @todo explain how to iterate over arrays + The Php::Value class also implements the begin() and end() methods that + you many STL containers has too. As a consequence, you can iterate + over an array just like you would iterate over a std::map class. +
++
+/**
+ * Function that accepts an array as parameter
+ * @param array
+ */
+void myFunction(const Php::Value &value)
+{
+ // assum the value variable holds an array or object, it then
+ // is possible to iterator over the values or properties
+ for (auto &iter : value)
+ {
+ // output key and value
+ std::cout << iter.first << ": " << iter.second << std::endl;
+ }
+}
+
+
++ The iterator treats the values in the Value class as variables of type + std::pair<Php::Value,Php::Value>. You can thus access the 'first' + and 'second' properties to retrieve either the key or the value.
-- cgit v1.2.3