1
我有一個輸入字段,我粘貼一個url,我想從url中獲取詳細信息,現在獲取結果後,我無法將這些值分配給輸入字段。您可以看到鏈接here檢索數組值不工作
<form action="" method="POST">
<input type="text" name="ref_url" placeholder="Paste the URL" value="https://www.lovely-cards.com/wedding-cards/1836-ethnica01.html">
<input type="submit" value="Get Details">
</form>
<input type="text" name="height" value="<?php echo $tags[0]['height']; ?>">
PHP
<?php
include('simple_html_dom.php');
if (!EMPTY(isset($_POST['ref_url']))) {
$url = $_POST['ref_url'];
$html = file_get_html($url);
$row = $html->find('tr');
unset($row[0]);
unset($row[1]);
foreach($row as $element) {
$tag_name = $element->find('td',0)->plaintext;
$tag_value = $element->find('td',1)->plaintext;
if (!EMPTY($tag_name) && !EMPTY($tag_value)) {
$tags[] = array($tag_name =>$tag_value);
}
}
echo '<pre>';
print_r($tags);
echo '</pre>';
}
?>
謝謝哥哥 – Naresh