LoginSignup
3
2

More than 5 years have passed since last update.

xpathで正規表現を使う (registerXpathPhpFunctionsの使い方)

Posted at
<?php
use Zend\Dom\Query;

$query = new Query();
$query->registerXpathPhpFunctions();
$query->setDocument(file_get_contents('http://ugnews.net/'));
$result = $query->queryXpath('//title[php:functionString("preg_match", "/ugnews/i", node()) = 1]');
var_dump($result->current()->nodeValue);
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2