我正在寻找的是一种从这些中搜索任何内容并取回所有字段的快速方法,例如,如果我在示例代码(如下所示)中搜索 favcolors 中的“red”,我会得到孩子最喜欢的人的名字color this is,即在这种情况下,返回一个包含 jhon 和 homer 的数组。如果搜索词是针对年龄 = 43 的人,则返回 homer,依此类推...:
<?php
class person {
public $name;
public $kidsfavcolors=array();
public $age;
}
$people['jhon'] = new person;
$people['jhon']->name = "jhon";
$people['jhon']->age = 30;
$people['jhon']->kidsfavcolors['katherine']= "red";
$people['jhon']->kidsfavcolors['jimmy']= "yellow";
$people['homer'] = new person;
$people['homer']->name = "homer";
$people['homer']->age = 43;
$people['homer']->kidsfavcolors['bart']= "black";
$people['homer']->kidsfavcolors['lisa']= "red";