Php ';数组';在我的foreach循环中显示

Php ';数组';在我的foreach循环中显示,php,arrays,Php,Arrays,出于某种原因,当我尝试执行foreach以回传数组中的值(有2个值)时,我将“array”一词作为输出。如果我在数组中使用print_r,这些显示很好,因此我知道它们在那里。我也尝试过使用as-list,但它只显示第一个值,后面什么也不显示 时间不早了,所以这可能是很愚蠢的事情!提前谢谢 <?php $crawl_url = "./emails.php"; function get_email($url) { $input = @file_get_contents($url);

出于某种原因,当我尝试执行foreach以回传数组中的值(有2个值)时,我将“array”一词作为输出。如果我在数组中使用print_r,这些显示很好,因此我知道它们在那里。我也尝试过使用as-list,但它只显示第一个值,后面什么也不显示

时间不早了,所以这可能是很愚蠢的事情!提前谢谢

<?php

$crawl_url = "./emails.php";

function get_email($url) {
    $input = @file_get_contents($url);
    $regexp = '/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i';
    preg_match_all($regexp, $input, $matches);

    if (empty($input)) {
        echo "No email addresses found";

    }   
    else {
        foreach($matches as $matches_values) {
            print $matches_values;
        }
    }
}

get_email($crawl_url);
echo '<br /> function complete';
?>

我认为您缺少$matches的0索引

试试这个:

foreach($matches[0] as $matches_values) {
    print $matches_values;
}

我认为你错过了$matches的0索引

试试这个:

foreach($matches[0] as $matches_values) {
    print $matches_values;
}

我认为你错过了$matches的0索引

试试这个:

foreach($matches[0] as $matches_values) {
    print $matches_values;
}

我认为你错过了$matches的0索引

试试这个:

foreach($matches[0] as $matches_values) {
    print $matches_values;
}