开发者

Is there a PHP library that facilitates manipulating html elements in a similar fashion to jquery?

开发者 https://www.devze.com 2023-04-08 06:45 出处:网络
PHP string manipulation functions are very counterintuitive and clunky, at least for me, and ev开发者_StackOverflow社区erytime I need to manipulate some html code before outputting it it takes too muc

PHP string manipulation functions are very counterintuitive and clunky, at least for me, and ev开发者_StackOverflow社区erytime I need to manipulate some html code before outputting it it takes too much time.

I was wondering if there was any PHP library that helps with this, preferably in a similar way to jQuery: retrieving and manipulating element attributes, selecting all the attributes with a given class, etc.


you can use phpquery or querypath. Here is a comprehensive tutorial about querypath.


There is a Dom Parser in PHP :

http://php.net/manual/en/class.domdocument.php


Sounds like you should be manipulating the HTML as a DOMdocument and using XPath (quite similar to jQuery selectors) to select the nodes.


Next to what silent answered, there is also FluentDOM which is not exactly jQuery mimicking, but provides fluent interfaces based on DomDocumentDocs.

0

精彩评论

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

关注公众号