phpquery

phpQuery finding the type of tag


I need to be able to determine the type of tag i have selected with phpQuery.

So, if i have the reference of an element, how can i easily figure out its tag type?

In jquery/js tagName will suffice or prop('tagName')

But in phpQuery i cannot seem to find a straight forward function to do this..

$doc = phpQuery::newDocumentFilePHP($ftp_file['local_path']);
if(!pq('.clasToFind')->length) {
      $tagType = pq('.clasToFind')->tagName;
}

Is the best answer regex the answer here?


Solution

  • tagName is a DomNode property. So when you iterate:

    foreach(pq('.clasToFind') as $el){
      echo $el->tagName;
    }