while循环preg_match

时间:2011-04-30 15:49:21

标签: php loops preg-match

我想循环:

$embed = array();
preg_match('@<embed.*?</embed>@s', $text, $embed);

如何循环$ embed?

谢谢!

2 个答案:

答案 0 :(得分:1)

foreach( $embed as $match ){}

或者这是一个棘手的问题吗?

答案 1 :(得分:0)

你如何制作循环?嗯,有几种方法......

#1...
foreach ($embed as $e) {
    #do stuff with $e as the current item
}

#2...
$len = count($embed);
for ($i = 0; $i < $len; $i++) {
    #do stuff with $embed[$i] as the current item
}
#or, with a while loop
#3...
while ($len--) {
    #do stuff with $embed[$i] as the current item
}