Similar to the Ruby way, I was wondering with the annonymous functions / closures etc.
$books->each = function($book) {
echo $book->name;
}
Is this kind of thing possible in PHP yet? If so could we see the features going more like this in Yii?
Page 1 of 1
Are these kinds of things possible?
#2
Posted 03 April 2012 - 02:04 PM
Well, if they are possible with PHP, they are possible with Yii as well. As for your example: No, I don't think closures work that way.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
#4
Posted 04 April 2012 - 03:44 AM
array_walk($books, function($book) { echo $book->name; });
or
$echoName = function(Book $book) {
echo $book->name;
};
array_walk($books, $echoName);
Share this topic:
Page 1 of 1

Help
















