mathsgod / p-query
Using jQuery liked method to parse html by using php
3.4.0
2024-05-16 03:24 UTC
Requires
- php: ^8.0
- symfony/css-selector: ^5.3
Requires (Dev)
- dev-master
- 3.4.0
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.2
- 3.0.1
- 3.0.0
- 2.4.0
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.16
- 2.0.15
- 2.0.14
- 2.0.13
- 2.0.12
- 2.0.11
- 2.0.10
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.2.0
- 1.1.15
- 1.1.14
- 1.1.13
- 1.1.12
- 1.1.11
- 1.1.10
- 1.1.2
- 1.1.1
- 1.1.0
This package is auto-updated.
Last update: 2024-10-16 04:18:53 UTC
README
Introduction
PQuery is a PHP library used to control html string by using jQuery liked method.
Example
require_once("vendor/autoload.php"); $p = p('<div class="container"> <div class="hello">Hello</div> </div>'); $p->find(".hello")->text("abc"); echo $p; /*output <div class="container"> <div class="hello">abc</div> </div> */
PQuery supported method
- size
- last
- first
- html
- prepend
- prependTo
- appendTo
- append
- attr
- after
- before
- css
- closest
- data
- addClass
- text
- contents
- children
- find
- remove
- removeAtt
- removeClass
- replaceWith
- required
- each
- val
- filter
- parent
- warp
- warpInner
- toggleClass
- hasClass
- prev
- next
- index
HTML element style and class
$div = new HTMLDivElement(); $div->classList->add("container"); $div->innerText = "Hello world!"; $div->style->color = "red"; echo $div; //<div class="container" style="color: red">Hello world!</div>
Element.append
Append an element
$div=new HTMLDivElement(); $p=new HTMLParagraphElement(); $div->append($p); echo $div; // <div><p></p></div>
Appending text
$div=new HTMLDivElement(); $div->append("Some text"); echo $div; // <div>Some text</div>
Appending an element and text
$div=new HTMLDivElement(); $p=new HTMLParagraphElement(); $div->append("Some text",$p); echo $div; // <div>Some text<p></p></div>
created by Raymond Chong