Search code examples
phpjqueryhtmlxmlhtml-parsing

jQuery-like interface for PHP?


I was curious as to whether or not there exists a jQuery-style interface/library for PHP for handling HTML/XML files -- specifically using jQuery style selectors.

I'd like to do things like this (all hypothetical):

foreach (j("div > p > a") as anchor) {
   // ...
}


print j("#some_id")->html();


print j("a")->eq(0)->attr("name");

These are just a few examples.

I did as much Googling as I could but couldn't find what I was looking for. Does anyone know if something along these lines exist, or is this something I'm going to have to make from scratch myself using domxml?


Solution

  • Doing some more hunting, I think I might've found precisely what I was looking for:

    phpQuery - jQuery port to PHP

    Thanks everyone for your answers, I will definitely keep them in mind for other uses.