Question

How to get a form with specific name using phpQuery?

<form method="POST" name="example">
        <input type="hidden"
...

My try:

include 'phpQuery-onefile.php';
//example site with this form
$html = file_get_contents("http://www.example.com");

$pq = phpQuery::newDocument($html);
$a = $pq->find("form name=example");
Was it helpful?

Solution

Use this...

$a = $pq->find("form[name=example]");

Source.

OTHER TIPS

phpQuery supports same CSS/jQuery like selectors, so this is what you want:

$a = pq("form[name=example]");

Note: Also change $pq->find to pq

Example:

phpQuery::newDocumentHTML('<form method="POST" name="example">Something</form>');
$a = pq("form[name=example]");
echo $a;

Result:

Something

In your case through, it will return form's html.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top