PHP | CachingIterator current()函数
CachingIterator::current()函数是PHP中的一个内置函数,用于返回当前元素。
句法:
mixed CachingIterator::current( void )
参数:此函数不接受任何参数。
返回值:该函数返回 CachingIterator 的当前值。
下面的程序说明了PHP中的 CachingIterator::current()函数:
方案一:
current() . " ";
}
?>
输出:
G e e k s
方案二:
"Geeks",
"b" => "for",
"c" => "Geeks",
"d" => "Computer",
"e" => "Science",
"f" => "Portal"
);
// Create a new CachingIterator
$cachIt = new CachingIterator(
new ArrayIterator($arr),
CachingIterator::FULL_CACHE
);
// Display the result
foreach($cachIt as $element) {
echo $cachIt->current() . "\n";
}
?>
输出:
Geeks
for
Geeks
Computer
Science
Portal
参考: https://www. PHP.net/manual/en/cachingiterator.current。 PHP