fit*_*low 13 php if-statement multidimensional-array query-expressions mongodb
我一直在寻找类似MongoDb(http://docs.mongodb.org/manual/applications/read/#find,docs.mongodb.org/manual/reference/operators/)查询表达式对象评估函数的实现或者一类.它可能不包括所有高级功能,并且应该具有可扩展的体系结构.
类似MongoDB的查询表达式对象易于理解和使用,提供编写干净,自解释代码的能力,因为要搜索的查询和对象都是关联数组.
基本上说它是一个方便的功能,从PHP数组中提取信息.知道了数组结构(arrayPath),它将允许对多维数组数据执行操作,而不需要多个嵌套循环.
如果您不熟悉MongoDb,请查看给定的表达式对象和数组以进行搜索.
为简单起见,我把它写成JSON字符串.对象内容毫无意义,只需显示MongoDb查询语法即可.
{
"name": "Mongo",
"type": "db",
"arch": {
"$in": [
"x86",
"x64"
]
},
"version": {
"$gte": 22
},
"released": {
"$or": {
"$lt": 2013,
"$gt": 2012
}
}
}
Run Code Online (Sandbox Code Playgroud)
[
{
"name": "Mongo",
"type": "db",
"release": {
"arch": "x86",
"version": 22,
"year": 2012
}
},
{
"name": "Mongo",
"type": "db",
"release": {
"arch": "x64",
"version": 21,
"year": 2012
}
},
{
"name": "Mongo",
"type": "db",
"release": {
"arch": "x86",
"version": 23,
"year": 2013
}
}
]
Run Code Online (Sandbox Code Playgroud)
因此,在函数的帮助下,我们应该能够向目标数组发出以下查询.
$found=findLikeMongo($array, $queryExpr); //resulting in a $array[0] value;
//@return found array
Run Code Online (Sandbox Code Playgroud)
$arrayPath=getPathFromMongo($array, $queryExpr);// resulting in array("0")
//@return array path, represented as an array where entries are consecutive keys.
Run Code Online (Sandbox Code Playgroud)
我发现goessner.net/articles/JsonPath/可能会覆盖我的需求(不是完全匹配,因为它使用类似Xpath的表达式),需要注意的是,它严重依赖于正则表达式和字符串解析,这肯定会慢下来与仅数组(JSON之类)实现相比,它更低.
此外,我在这里找到了一个类似的问题,@ stackoverflow 在PHP中评估类似
MongoDB的JSON查询.得到的答案是使用一些SPL函数,我习惯在大多数情况下避免使用它们.
不知道作者是否提出了功能,他一直在努力发展.
可能的阵列路径实现是在那里找到了/content/dealing-deep-arrays-php,因此缺乏这种实现,它依赖于指针.
我知道这不是一个关于oneliner答案的微不足道的问题,这就是为什么我在开始我自己的类的实际开发之前问它.
我欣赏架构技巧,相关或类似的代码,这可能是一个很好的实践示例,用于动态构建php"if..else"表达式.强调文字
@Baba提供了一个优秀的课程,使用SPL编写.我想知道如何在没有SPL的情况下重写这段代码.
创建的ArrayQuery类在Github 上发布,考虑检出存储库以获取更新.
简单来说-




$m = new MongoClient(); // connect
$db = $m->testmongo; // select a database
$collection = $db->data;
$loops=100;
for ($i=0; $i<$loops; $i++) {
$d = $collection->find(array("release.year" => 2013));
}
print_r( iterator_to_array($d) );
Run Code Online (Sandbox Code Playgroud)
include('data.php');
include('phpmongo-spl.php');
$s = new ArrayCollection($array, array("release.year" => 2013),false);
$loops=100;
for ($i=0; $i<$loops; $i++) {
$d = $s->parse();
}
print_r( $d );
Run Code Online (Sandbox Code Playgroud)
在SPL类 解析()函数已被稍微修改执行后返回的值,它可能也被修改为接受的表达,但它不是作为表达式被重新评估每一次剖析目的是必不可少的.
include('data.php');
include('phpmongo-raw.php');
$s = new ArrayStandard($array);
$loops=100;
for ($i=0; $i<$loops; $i++) {
$d = $s->find(array("release.year" => 2013));
}
print_r( $d );
Run Code Online (Sandbox Code Playgroud)
<?php
include('data.php');
include('../chequer2/Chequer.php');
$query=array("release.year" => 2013);
$loops=100;
for ($i=0; $i<$loops; $i++) {
$result=Chequer::shorthand('(.release.year > 2012) ? (.) : NULL')
->walk($array);
}
print_r($result);
?>
Run Code Online (Sandbox Code Playgroud)
$json = '[{
"name":"Mongo",
"type":"db",
"release":{
"arch":"x86",
"version":22,
"year":2012
}
},
{
"name":"Mongo",
"type":"db",
"release":{
"arch":"x64",
"version":21,
"year":2012
}
},
{
"name":"Mongo",
"type":"db",
"release":{
"arch":"x86",
"version":23,
"year":2013
}
},
{
"key":"Diffrent",
"value":"cool",
"children":{
"tech":"json",
"lang":"php",
"year":2013
}
}
]';
$array = json_decode($json, true);
Run Code Online (Sandbox Code Playgroud)
<!doctype html>
<html>
<head>
<style>
body {margin : 0px}
</style>
</head>
<body>
<div class="forp"></div>
<?php
register_shutdown_function(
function() {
// next code can be append to PHP scripts in dev mode
?>
<script src="../forp-ui/js/forp.min.js"></script>
<script>
(function(f) {
f.find(".forp")
.each(
function(el) {
el.css('margin:50px;height:300px;border:1px solid #333');
}
)
.forp({
stack : <?php echo json_encode(forp_dump()); ?>,
//mode : "fixed"
})
})(forp);
</script>
<?php
}
);
// start forp
forp_start();
// our PHP script to profile
include($_GET['profile']);
// stop forp
forp_end();
?>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
Bab*_*aba 10
我认为在PHP中评估类似MongoDB的JSON查询已经提供了所需的所有信息.您所需要的只是通过解决方案创造性,并实现您想要的
数组
让我们假设我们将以下json转换为数组
$json = '[{
"name":"Mongo",
"type":"db",
"release":{
"arch":"x86",
"version":22,
"year":2012
}
},
{
"name":"Mongo",
"type":"db",
"release":{
"arch":"x64",
"version":21,
"year":2012
}
},
{
"name":"Mongo",
"type":"db",
"release":{
"arch":"x86",
"version":23,
"year":2013
}
},
{
"key":"Diffrent",
"value":"cool",
"children":{
"tech":"json",
"lang":"php",
"year":2013
}
}
]';
$array = json_decode($json, true);
Run Code Online (Sandbox Code Playgroud)
例1
检查key- Different是否会如此简单
echo new ArrayCollection($array, array("key" => "Diffrent"));
Run Code Online (Sandbox Code Playgroud)
产量
{"3":{"key":"Diffrent","value":"cool","children":{"tech":"json","lang":"php","year":2013}}}
Run Code Online (Sandbox Code Playgroud)
实施例2
检查是否release year是2013
echo new ArrayCollection($array, array("release.year" => 2013));
Run Code Online (Sandbox Code Playgroud)
产量
{"2":{"name":"Mongo","type":"db","release":{"arch":"x86","version":23,"year":2013}}}
Run Code Online (Sandbox Code Playgroud)
例3
算哪里Year是2012
$c = new ArrayCollection($array, array("release.year" => 2012));
echo count($c); // output 2
Run Code Online (Sandbox Code Playgroud)
例4
让您要检查您的示例中采取version的grater than 22
$c = new ArrayCollection($array, array("release.version" => array('$gt'=>22)));
echo $c;
Run Code Online (Sandbox Code Playgroud)
产量
{"2":{"name":"Mongo","type":"db","release":{"arch":"x86","version":23,"year":2013}}}
Run Code Online (Sandbox Code Playgroud)
例5
检查release.arch值是否IN为[x86,x100](例如)
$c = new ArrayCollection($array, array("release.arch" => array('$in'=>array("x86","x100"))));
foreach($c as $var)
{
print_r($var);
}
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[name] => Mongo
[type] => db
[release] => Array
(
[arch] => x86
[version] => 22
[year] => 2012
)
)
Array
(
[name] => Mongo
[type] => db
[release] => Array
(
[arch] => x86
[version] => 23
[year] => 2013
)
)
Run Code Online (Sandbox Code Playgroud)
例6
使用Callable
$year = 2013;
$expression = array("release.year" => array('$func' => function ($value) use($year) {
return $value === 2013;
}));
$c = new ArrayCollection($array, $expression);
foreach ( $c as $var ) {
print_r($var);
}
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[name] => Mongo
[type] => db
[release] => Array
(
[arch] => x86
[version] => 23
[year] => 2013
)
)
Run Code Online (Sandbox Code Playgroud)
例7
注册您自己的表达式名称
$c = new ArrayCollection($array, array("release.year" => array('$baba' => 3)), false);
$c->register('$baba', function ($a, $b) {
return substr($a, - 1) == $b;
});
$c->parse();
echo $c;
Run Code Online (Sandbox Code Playgroud)
产量
{"2":{"name":"Mongo","type":"db","release":{"arch":"x86","version":23,"year":2013}}}
Run Code Online (Sandbox Code Playgroud)
使用的类
class ArrayCollection implements IteratorAggregate, Countable, JsonSerializable {
private $array;
private $found = array();
private $log;
private $expression;
private $register;
function __construct(array $array, array $expression, $parse = true) {
$this->array = $array;
$this->expression = $expression;
$this->registerDefault();
$parse === true and $this->parse();
}
public function __toString() {
return $this->jsonSerialize();
}
public function jsonSerialize() {
return json_encode($this->found);
}
public function getIterator() {
return new ArrayIterator($this->found);
}
public function count() {
return count($this->found);
}
public function getLog() {
return $this->log;
}
public function register($offset, $value) {
if (strpos($offset, '$') !== 0)
throw new InvalidArgumentException('Expresiion name must always start with "$" sign');
if (isset($this->register[$offset]))
throw new InvalidArgumentException(sprintf('Expression %s already registred .. Please unregister It first'));
if (! is_callable($value)) {
throw new InvalidArgumentException(sprintf('Only callable value can be registred'));
}
$this->register[$offset] = $value;
}
public function unRegister($offset) {
unset($this->register[$offset]);
}
public function parse() {
$it = new RecursiveIteratorIterator(new RecursiveArrayIterator($this->array));
foreach ( $it as $k => $items ) {
if ($this->evaluate($this->getPath($it), $items)) {
$this->found[$it->getSubIterator(0)->key()] = $this->array[$it->getSubIterator(0)->key()];
}
}
}
private function registerDefault() {
$this->register['$eq'] = array($this,"evaluateEqal");
$this->register['$not'] = array($this,"evaluateNotEqual");
$this->register['$gte'] = array($this,"evaluateGreater");
$this->register['$gt'] = array($this,"evaluateGreater");
$this->register['$lte'] = array($this,"evaluateLess");
$this->register['$lt'] = array($this,"evaluateLess");
$this->register['$in'] = array($this,"evalueateInset");
$this->register['$func'] = array($this,"evalueateFunction");
$this->register['$fn'] = array($this,"evalueateFunction");
$this->register['$f'] = array($this,"evalueateFunction");
}
private function log($log) {
$this->log[] = $log;
}
private function getPath(RecursiveIteratorIterator $it) {
$keyPath = array();
foreach ( range(1, $it->getDepth()) as $depth ) {
$keyPath[] = $it->getSubIterator($depth)->key();
}
return implode(".", $keyPath);
}
private function checkType($a, $b) {
if (gettype($a) != gettype($b)) {
$this->log(sprintf("%s - %s is not same type of %s - %s", json_encode($a), gettype($a), json_encode($b), gettype($b)));
return false;
}
return true;
}
private function evaluate($key, $value) {
$o = $r = 0; // Obigation & Requirement
foreach ( $this->expression as $k => $options ) {
if ($k !== $key)
continue;
if (is_array($options)) {
foreach ( $options as $eK => $eValue ) {
if (strpos($eK, '$') === 0) {
$r ++;
$callable = $this->register[$eK];
$callable($value, $eValue) and $o ++;
} else {
throw new InvalidArgumentException('Missing "$" in expession key');
}
}
} else {
$r ++;
$this->evaluateEqal($value, $options) and $o ++;
}
}
return $r > 0 && $o === $r;
}
private function evaluateEqal($a, $b) {
return $a == $b;
}
private function evaluateNotEqual($a, $b) {
return $a != $b;
}
private function evaluateLess($a, $b) {
return $this->checkType($a, $b) and $a < $b;
}
private function evaluateGreater($a, $b) {
return $this->checkType($a, $b) and $a > $b;
}
private function evalueateInset($a, array $b) {
return in_array($a, $b);
}
private function evalueateFunction($a, callable $b) {
return $b($a);
}
}
Run Code Online (Sandbox Code Playgroud)
它可能不包括所有高级功能,并且应该具有可扩展的体系结构
上面的类显示了你想要的典型例子..你可以轻松实现decouple它,扩展它以支持像$and和的复合表达式$or
类似MongoDB的查询表达式对象易于理解和使用,提供编写干净,自解释代码的能力,因为要搜索的查询和对象都是关联数组.
为什么不把数组写入MongoDB数据库而不是数组呢?它更有效率,它可以为您节省很多麻烦
我还必须提到使用最好的工具来获得最佳工作......你想要的基本上是数据库的功能
基本上说它是一个方便的功能,从PHP数组中提取信息.知道了数组结构(arrayPath),它将允许对多维数组数据执行操作,而不需要多个嵌套循环.
该示例显示了如何使用路径搜索值,但仍然依赖于将数组加载到内存中,并且您的类执行多个递归ans循环,这不像数据库那样高效.
我欣赏架构技巧,相关或类似的代码,这可能是一个很好的实践示例,用于动态构建php"if..else"表达式.
你真的是说你想要所有那些就在这里吗???
@baba给出了一个很好的原始PHP版本的类,实现类似MongoDB的查询表达式对象评估,但输出结构略有不同,我的意思是嵌套数组输出中的点符号([release.arch] => x86),而不是常规数组([release] => Array([arch] => x86)).我将非常感谢您的提示如何使该类与mongoDB完全兼容,因为它似乎严格依赖于原始的PHP类实现.
================================================== =====================
回答:
你想要的是非常简单的,你需要的只是2 corrections当前的代码输入和输出循环,你会得到你的新格式.
我的意思是什么?
A.改变了
foreach ( $array as $part ) {
$this->flatten[] = $this->convert($part);
}
Run Code Online (Sandbox Code Playgroud)
至
foreach ( $array as $k => $part ) {
$this->flatten[$k] = $this->convert($part);
}
Run Code Online (Sandbox Code Playgroud)
B.改变了
foreach ( $this->flatten as $data ) {
$this->check($find, $data, $type) and $f[] = $data;
}
Run Code Online (Sandbox Code Playgroud)
至:
foreach ( $this->flatten as $k => $data ) {
$this->check($find, $data, $type) and $f[] = $this->array[$k];
}
Run Code Online (Sandbox Code Playgroud)
用于休息的新数组
$json = '[
{
"name": "Mongo",
"release": {
"arch": "x86",
"version": 22,
"year": 2012
},
"type": "db"
},
{
"name": "Mongo",
"release": {
"arch": "x64",
"version": 21,
"year": 2012
},
"type": "db"
},
{
"name": "Mongo",
"release": {
"arch": "x86",
"version": 23,
"year": 2013
},
"type": "db"
},
{
"name": "MongoBuster",
"release": {
"arch": [
"x86",
"x64"
],
"version": 23,
"year": 2013
},
"type": "db"
},
{
"children": {
"dance": [
"one",
"two",
{
"three": {
"a": "apple",
"b": 700000,
"c": 8.8
}
}
],
"lang": "php",
"tech": "json",
"year": 2013
},
"key": "Diffrent",
"value": "cool"
}
]';
$array = json_decode($json, true);
Run Code Online (Sandbox Code Playgroud)
简单测试
$s = new ArrayStandard($array);
print_r($s->find(array("release.arch"=>"x86")));
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[0] => Array
(
[name] => Mongo
[type] => db
[release] => Array
(
[arch] => x86
[version] => 22
[year] => 2012
)
)
[1] => Array
(
[name] => Mongo
[type] => db
[release] => Array
(
[arch] => x86
[version] => 23
[year] => 2013
)
)
)
Run Code Online (Sandbox Code Playgroud)
如果你还想保留原作,array key position你可以拥有
foreach ( $this->flatten as $k => $data ) {
$this->check($find, $data, $type) and $f[$k] = $this->array[$k];
}
Run Code Online (Sandbox Code Playgroud)
只是为了好玩的部分
A.支持regex
只是为了好玩,我添加了$regex对别名的支持$preg或者$match你可以拥有的意义
print_r($s->find(array("release.arch" => array('$regex' => "/4$/"))));
Run Code Online (Sandbox Code Playgroud)
要么
print_r($s->find(array("release.arch" => array('$regex' => "/4$/"))));
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[1] => Array
(
[name] => Mongo
[type] => db
[release] => Array
(
[arch] => x64
[version] => 21
[year] => 2012
)
)
)
Run Code Online (Sandbox Code Playgroud)
B.使用简单数组queries
$queryArray = array(
"release" => array(
"arch" => "x86"
)
);
$d = $s->find($s->convert($queryArray));
Run Code Online (Sandbox Code Playgroud)
$s->convert($queryArray) 已转换
Array
(
[release] => Array
(
[arch] => x86
)
)
Run Code Online (Sandbox Code Playgroud)
至
Array
(
[release.arch] => x86
)
Run Code Online (Sandbox Code Playgroud)
C.模数$mod
print_r($s->find(array(
"release.version" => array(
'$mod' => array(
23 => 0
)
)
)));
//Checks release.version % 23 == 0 ;
Run Code Online (Sandbox Code Playgroud)
D.计算元素$size
print_r($s->find(array(
"release.arch" => array(
'$size' => 2
)
)));
// returns count(release.arch) == 2;
Run Code Online (Sandbox Code Playgroud)
E.检查它是否与数组中的所有元素匹配$all
print_r($s->find(array(
"release.arch" => array(
'$all' => array(
"x86",
"x64"
)
)
)));
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[3] => Array
(
[name] => MongoBuster
[release] => Array
(
[arch] => Array
(
[0] => x86
[1] => x64
)
[version] => 23
[year] => 2013
)
[type] => db
)
)
Run Code Online (Sandbox Code Playgroud)
F.如果你不知道该元素的键名,那么你CA使用$has它像opposite的$in
print_r($s->find(array(
"release" => array(
'$has' => "x86"
)
)));
Run Code Online (Sandbox Code Playgroud)
================================================== =====================
@Baba提供了一个优秀的课程,使用SPL编写.我想知道如何在没有SPL的情况下重写这段代码.原因是多次调用此类将产生函数开销,可以避免在原始PHP中重写它,并且可能在最终版本中使用goto语句,以避免递归函数调用.
================================================== =====================
既然你不想要SPL和功能..它花了一段时间,但我能够提出灵活易用的替代课程
为避免多次加载数组,请将其声明一次:
$array = json_decode($json, true);
$s = new ArrayStandard($array);
Run Code Online (Sandbox Code Playgroud)
A.找到在哪里release.year是2013
$d = $s->find(array(
"release.year" => "2013"
));
print_r($d);
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[0] => Array
(
[name] => Mongo
[type] => db
[release.arch] => x86
[release.version] => 23
[release.year] => 2013
)
)
Run Code Online (Sandbox Code Playgroud)
B.第一次你可以运行复杂$and或$or语句如find where release.arch= x86和release.year=2012
$d = $s->find(array(
"release.arch" => "x86",
"release.year" => "2012"
), ArrayStandard::COMPLEX_AND);
print_r($d);
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[0] => Array
(
[name] => Mongo
[type] => db
[release.arch] => x86
[release.version] => 22
[release.year] => 2012
)
)
Run Code Online (Sandbox Code Playgroud)
C.想象一个更复杂的查询
$d = $s->find(array(
"release.year" => array(
'$in' => array(
"2012",
"2013"
)
),
"release.version" => array(
'$gt' => 22
),
"release.arch" => array(
'$func' => function ($a) {
return $a == "x86";
}
)
), ArrayStandard::COMPLEX_AND);
print_r($d);
Run Code Online (Sandbox Code Playgroud)
产量
Array
(
[0] => Array
(
[name] => Mongo
[type] => db
[release.arch] => x86
[release.version] => 23
[release.year] => 2013
)
)
Run Code Online (Sandbox Code Playgroud)
新的Modified类
class ArrayStandard {
const COMPLEX_OR = 1;
const COMPLEX_AND = 2;
private $array;
private $tokens;
private $found;
function __construct(array $array) {
$this->array = $array;
foreach ( $array as $k => $item ) {
$this->tokens[$k] = $this->tokenize($item);
}
}
public function getTokens() {
return $this->tokens;
}
public function convert($part) {
return $this->tokenize($part, null, false);
}
public function find(array $find, $type = 1) {
$f = array();
foreach ( $this->tokens as $k => $data ) {
$this->check($find, $data, $type) and $f[$k] = $this->array[$k];
}
return $f;
}
private function check($find, $data, $type) {
$o = $r = 0; // Obigation & Requirement
foreach ( $data as $key => $value ) {
if (isset($find[$key])) {
$r ++;
$options = $find[$key];
if (is_array($options)) {
reset($options);
$eK = key($options);
$eValue = current($options);
if (strpos($eK, '$') === 0) {
$this->evaluate($eK, $value, $eValue) and $o ++;
} else {
throw new InvalidArgumentException('Missing "$" in expession key');
}
} else {
$this->evaluate('$eq', $value, $options) and $o ++;
}
}
}
if ($o === 0)
return false;
if ($type == self::COMPLEX_AND and $o !== $r)
return false;
return true;
}
private function getValue(array $path) {
return count($path) > 1 ? $this->getValue(array_slice($path, 1), $this->array[$path[0]]) : $this->array[$path[0]];
}
private function tokenize($array, $prefix = '', $addParent = true) {
$paths = array();
$px = empty($prefix) ? null : $prefix . ".";
foreach ( $array as $key => $items ) {
if (is_array($items)) {
$addParent && $paths[$px . $key] = json_encode($items);
foreach ( $this->tokenize($items, $px . $key) as $k => $path ) {
$paths[$k] = $path;
}
} else {
$paths[$px . $key] = $items;
}
}
return $paths;
}
private function evaluate($func, $a, $b) {
$r = false;
switch ($func) {
case '$eq' :
$r = $a == $b;
break;
case '$not' :
$r = $a != $b;
break;
case '$gte' :
case '$gt' :
if ($this->checkType($a, $b)) {
$r = $a > $b;
}
break;
case '$lte' :
case '$lt' :
if ($this->checkType($a, $b)) {
$r = $a < $b;
}
break;
case '$in' :
if (! is_array($b))
throw new InvalidArgumentException('Invalid argument for $in option must be array');
$r = in_array($a, $b);
break;
case '$has' :
if (is_array($b))
throw new InvalidArgumentException('Invalid argument for $has array not supported');
$a = @json_decode($a, true) ? : array();
$r = in_array($b, $a);
break;
case '$all' :
$a = @json_decode($a, true) ? : array();
if (! is_array($b))
throw new InvalidArgumentException('Invalid argument for $all option must be array');
$r = count(array_intersect_key($a, $b)) == count($b);
break;
case '$regex' :
case '$preg' :
case '$match' :
$r = (boolean) preg_match($b, $a, $match);
break;
case '$size' :
$a = @json_decode($a, true) ? : array();
$r = (int) $b == count($a);
break;
case '$mod' :
if (! is_array($b))
throw new InvalidArgumentException('Invalid argument for $mod option must be array');
list($x, $y) = each($b);
$r = $a % $x == 0;
break;
case '$func' :
case '$fn' :
case '$f' :
if (! is_callable($b))
throw new InvalidArgumentException('Function should be callable');
$r = $b($a);
break;
default :
throw new ErrorException("Condition not valid ... Use \$fn for custom operations");
break;
}
return $r;
}
private function checkType($a, $b) {
if (is_numeric($a) && is_numeric($b)) {
$a = filter_var($a, FILTER_SANITIZE_NUMBER_FLOAT);
$b = filter_var($b, FILTER_SANITIZE_NUMBER_FLOAT);
}
if (gettype($a) != gettype($b)) {
return false;
}
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1537 次 |
| 最近记录: |