开发者

php: php simple dom parser question

i开发者_如何学运维'm using the php simple dom parser and found a little issue:

when the selector returns only one element, i also need to run a foreach loop for it. is there a simpler way to do it?

thanks


The manual says find() has a second parameter for exactly that:

mixed find ( string $selector [, int $index] )

Find elements by the CSS selector. Returns the Nth element object if index is set, otherwise return an array of object.

So in your case,

$txt = $ctl->find("input", 0); 

should do the job.

SimpleHTMLDOM API reference

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜