In the docs for phpQuery, it states that when you loop with foreach
a php DOM is returned. This must be passed back to phpQuery useing pq().
Change all occurances of $stuffs
to pq($stuffs)
Out of curiosity I did the following as I have never used phpQuery before:
<?
require 'phpQuery-onefile.php';
$html = "<table id=\"xp\">
<tbody >
<tr>
<td>
<input type=\"text\" data-type=\"string\" value=\"testvalue\" class=\"text\">
</td>
<td>
<input type=\"text\" data-type=\"string\" value=\"\" class=\"text\">
</td>
</tr>
</tbody>
</table>";
$pq = phpQuery::newDocument($html);
foreach(pq('.text') as $stuffs)
{
pq($stuffs)->val('ompalompa');
echo pq($stuffs)->val()."</br>";
}
?>
The output was:
ompalompa
ompalompa
If I use:
$stuffs->val('ompalompa');
Then
Fatal error: Call to undefined method DOMElement::val() in /var/www/index.php on line 20