PHP code example of jeremiah-shaulov / joyquery-php

1. Go to this page and download the library: Download jeremiah-shaulov/joyquery-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jeremiah-shaulov / joyquery-php example snippets




yQuery\JoyQuery;

$doc = new DOMDocument;
$doc->loadHTML('<div class=d hello=world><span>Hello</span></div>');
foreach (JoyQuery::evaluate('.d span:last-child', $doc) as $elem)
{	echo "Found: ", $doc->saveXml($elem->cloneNode(true)), "\n\n";
}



yQuery\JoyQuery;

JoyQuery::$FUNCTIONS['has_text'] = function(DOMElement $node, $text)
{	return strpos($node->textContent, $text) !== false;
};

$doc = new DOMDocument;
$doc->loadHTML('<p>One</p> <p>Two</p> <p>Three</p>');
foreach (JoyQuery::evaluate('p:has-text("ee")', $doc) as $elem)
{	echo "Found: ", $doc->saveXml($elem->cloneNode(true)), "\n\n";
}

composer