Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道是否有办法对显示的 XML 结果设置限制?
就像在 php/mysql 中一样:SELECT * FROM blablabla ORDER BY RAND() LIMIT 0,44
SELECT * FROM blablabla ORDER BY RAND() LIMIT 0,44
但是在 10 条记录后停止 XML Parse..
谢谢!
你需要某种计数器。如果你想把事情留在一个foreach循环中:
foreach
$i = 0; foreach($xml as $xmls) { // do stuff here $i++; if($i == 10) break; }
或者如果你想使用for循环:
for
for ($i = 0; $i < 10; $i++) { $xmls = $xml[$i]; // do stuff here }