Home > php教程 > php手册 > codeplex:PHP LINQ classes,PHP也可以使用Linq语法操作对象

codeplex:PHP LINQ classes,PHP也可以使用Linq语法操作对象

WBOY
Release: 2016-06-06 19:59:57
Original
1056 people have browsed it

Examples can be found in the test package in the latest release. A basic example Let's say we have an array of strings and want to select only the strings whose length is 5. The PHPLinq way of achieving this would be the following: // Crea

Examples can be found in the test package in the latest release.

A basic example

Let's say we have an array of strings and want to select only the strings whose length is
// Create data source
$names = array("John", "Peter", "Joe", "Patrick", "Donald", "Eric"); 

$result = from('$name')->in($names)
            ->where('$name => strlen($name) select('$name'); 
Copy after login

Feels familiar to SQL? Yes indeed! No more writing a loop over this array, checking the string's length, and adding it to a temporary variable. 
You may have noticed something strange... What's that $name => strlen($name)

http://www.weiqinxue.cn/blogs/index.php/User/articleview/ArticleID/U2A15

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template