[英]Getting element in PHP - PHP Simple HTML DOM Parser
你能幫我解決下面的問題嗎? 我在 html 中有以下代碼:
<div class="return-form">
<div class="two_cols">
<div class="first_col">
<label for="namesinger">Name:</label> </div>
<div class="second_col">
<p id="name">Axl Rose</p>
</div>
</div>
我正在使用 PHP Simple HTML DOM Parser 庫,我想在屏幕上只顯示名稱“Axl Rose”。
echo ($ name)
預計退出 Axl Rose
這是您提取數據的方式
<?php
// Load the HTML
$html = str_get_html('<div class="return-form">
<div class="two_cols">
<div class="first_col">
<label for="namesinger">Name:</label> </div>
<div class="second_col">
<p id="name">Axl Rose</p>
</div>
</di');
// Locate the date via div ID and display
echo $html->find('p[id=name]', 0)->plaintext;
?>
有關更多詳細信息,請閱讀此
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.