php - LINQ expressions? -
is there way use linq expressions in php? example, in c# can following:
list<string> names = new list<string>() { "francisco", "ronald", "araújo", "barbosa" }; var onename = names.where(x => x.equals("ronald")).firstordefault(); and in php, how following?
names **.where** (x => x.equals("ronald")) **.firstordefault()**;
there few php libraries mimic functionalities of linq. examples are:
in phplinq code this:
$names = array("francisco", "ronald", "araújo", "barbosa"); $onename = from('$name')->in($names) ->where('$x => $x == "ronald"') ->firstordefault('$name'); or pinq takes different approach php 5.3+ closures:
$onename = \pinq\traversable::from($names) ->where(function ($x) { return $x == 'ronald'; }) ->first();
Comments
Post a Comment