检索不起作用的数组值

时间:2016-12-14 08:42:07

标签: php html arrays file input

我有一个输入字段,我粘贴了一个网址,我想从网址中获取详细信息。现在获取结果后,我无法将这些值分配给输入字段。您可以看到链接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>';
}

?>

1 个答案:

答案 0 :(得分:0)

它的'高度'不是你试图设置的'高度'