本文整理匯總了PHP中ArrayList::getByFunctionVale方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayList::getByFunctionVale方法的具體用法?PHP ArrayList::getByFunctionVale怎麽用?PHP ArrayList::getByFunctionVale使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArrayList
的用法示例。
在下文中一共展示了ArrayList::getByFunctionVale方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: TestClass
//This is the object we want to find in the list.
$list->add($x);
$x = new TestClass(1);
$list->add($x);
$x = new TestClass(69);
$list->add($x);
$x = new TestClass(420);
$list->add($x);
$x = new TestClass(1337);
$list->add($x);
//Now try and find the object with the value we want
$object = $list->getByFunctionVale('getData', 90);
echo 'Found Object ' . $object->getData();
//Prints 90
//Using Strict Comparison (For Object based searching)
//Create the list
$list = new ArrayList('TestClass');
$sub_objectA = new TestClass('Whatever Sub Object A');
$sub_objectB = new TestClass('Whatever Sub Object B');
$sub_objectC = new TestClass('Whatever Sub Object C');
//Create our Objects
$x = new TestClass($sub_objectA);
$list->add($x);
$x = new TestClass($sub_objectB);
//We want to find this.
$list->add($x);
$x = new TestClass($sub_objectC);
$list->add($x);
$object = $list->getByFunctionVale('getData', $sub_objectB);
echo 'Found Object ' . $object->getData()->getData();
//Prints "Whatever Sub Object B"