Chainable.
public static newDocumentFileXHTML ( $file, $charset = null ) : phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery | ||
리턴 | phpQueryObject | QueryTemplatesSource | QueryTemplatesParse | QueryTemplatesSourceQuery |
<?php /* Layercake 1.0 Copyright(c) 2010 by Jesse Breuer distributed under the terms of the GNU General Public License. */ require 'process/phpQuery-onefile.php'; $doc = phpQuery::newDocumentFileXHTML('./input.htm'); function array_push_assoc($array, $key, $value) { //needed to add associative attr=>value pairs to the array $array[$key] = $value; return $array; } //close function $attrs = array("id", "class", "bgc", "txc", "bdc", "fts", "flh", "ilh", "wid", "cmn", "amn", "tmn", "rmn", "bmn", "lmn", "abd", "tbd", "rbd", "bbd", "lbd", "apd", "tpd", "rpd", "bpd", "lpd", "innerWidth"); //list all of the attributes. $attrsLength = count($attrs) - 1; $removables = array_slice($attrs, 2); //the ones we will strip out at the end $removablesLength = count($removables) - 1; $divs = array(); //make the divs an associative array containing attr=>value pairs $numberOfDivs = $doc["div"]->size() - 1; for ($i = 0; $i <= $numberOfDivs; $i++) { //loop through the divs to build an array $divs[$i] = array(); for ($j = 0; $j <= $attrsLength; $j++) { //loop through the attribute => value pairs for each div in the array $valueOfAttr = $doc["div:eq({$i})"]->attr("{$attrs[$j]}"); $divs[$i] = array_push_assoc($divs[$i], $attrs[$j], $valueOfAttr); }