Closed CezaryDanielNowak closed 10 years ago
in mammouth you can use this: http://mammouth.wamalaka.com/#try:{{%0Acontact%20%3D%20[]%0Afor%20contact%20of%20contacts%0A%20%20echo%28contact%29%0A}} For doc: http://mammouth.wamalaka.com/#for
For is good for arrays, not for objects/dicts
I think that foreach
of PHP is always used with arrays, not with with objects/dicts, do you have any examples??
Sure. For example working with object database rows:
<?php
/* ... */
$to_edit = mysql_fetch_object($pointer);
foreach($to_edit as $key => $value) {
echo "<input type='text' name='{$key}' value='" . htmlspecialchars($value, ENT_QUOTES) . "'>\n";
}
?>
additionally: break & continue are compiled to /error/ and $continue;
I have add break & continue statements now: e682a49ad176fc24f36e2d7c97d2e0cb78442b7e
+1 Any news about foreach? Its really important cause $key part and use with any iterator (includes objects). More info here - http://php.net/iterator
foreach is also useful for arrays with non-numeric keys.
@pwhelan, we'are working on this :) tnx you...
The easy solution, at least from an outside perspective, is to use foreach under the hood for 'for x of y'. That way all forms of iterators and arrays are supported.
Mammouth support now for each
see documentation http://mammouth.wamalaka.com/#loops
There is no such thing as foreach in mammouth. http://www.php.net/manual/en/control-structures.foreach.php