0

HTML:

<input type="hidden" id="_wpnonce" name="_wpnonce" value="12345678" />
<input type="hidden" name="_wp_http_referer" value="someurl/?album=1&amp;gallery=15" />

galleryこの場合の id を取得する必要があり15ます。

これを達成しようとしている方法:

$html = <input type="hidden" id="_wpnonce" name="_wpnonce" value="12345678" />
<input type="hidden" name="_wp_http_referer" value="someurl/?album=1&amp;gallery=15" />";
$dom = new DOMDocument;
$dom->loadHTML($html);
$xpath = new DOMXpath( $dom);
$galleryid = $xpath->query(//how to get gallery id?); 
4

5 に答える 5

0

簡単な解決策が必要な場合:

$found = preg_match('/gallery=[0-9]+/', $html, $match);
$gallery_id = (int)substr($match[0], strlen("gallery="));
于 2013-08-06T12:05:49.803 に答える