ここに私が試した例があります
<?php
include 'spider/classes/simple_html_dom.php';
$html = new simple_html_dom();
$html->load("<html><body><h2>Heading 1</h2><h2>This heading 2</h2></p></p></body></html>");
$e = $html->find("h2", 0);
$key = array();
if($e->plaintext != ""){
foreach($html->find("h2", 0) as $e){
//echo $e->plaintext;
array_push($key, $e->plaintext);
}
} else {
echo "error";
}
print_r($key);
?>
結果:
配列 ( [0] => [1] => [2] => [3] => [4] => [5] => 見出し 1この見出し 2
[6] => [7] => )
array_push を使用して配列を作成するにはどうすればよいですか?