情況:在數組中有160個ID,需要建立xml請求,最多50個集合並分別提交每個集合。PHP:每50個項目的循環函數
問題:如何循環功能,並與ID 51功能doBatch($ IDS)
簡化的代碼繼續:
function doBatch($ids)
{
$start = "<feed>";
foreach($ids as $id)
{
$add .= '<entry>'$id.'</entry>';
}
$stop = "</feed>";
$data = $start.$add.$stop;
post($data);
}
是數字索引的$ ids數組? – stillstanding 2010-10-08 13:31:25
您是否問如何在應用程序實例之間保持狀態,以便每次運行腳本時都會批量處理下一組50個ID?或者這個程序只運行一次,並且簡單地多次調用'doBatch'? – meagar 2010-10-08 13:43:11
ID是Youtube視頻ID(如Ez_XAQKUiL8)。 該腳本將運行一次,並將多次調用doBatch – MeProtozoan 2010-10-08 13:46:16