【发布时间】:2017-04-29 12:29:07
【问题描述】:
我有一个输入字段,我在其中粘贴一个 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>';
}
?>
【问题讨论】:
标签: php html arrays file input