K
K
khodos_dmitry2017-06-23 08:37:43
PHP
khodos_dmitry, 2017-06-23 08:37:43

How to tell if phpQuery didn't find anything?

And how to write it in an if condition?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Samarkand, 2017-06-28
@khodos_dmitry

if (pq($document['div'])->length() == 0) {}

Y
Yakov Vylegzhanin, 2017-06-23
@vylegzhanin

Not sure, but you can try:

$document = phpQuery::newDocument( /* url */ );

if(count($document->find('div')) > 0) { }
// или
if(!empty($document->find('div'))) { }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question