$source = "(・・・数千文字あるので省略します)" $data = '/<td class="c">\s*.*\s*<\/td>|<td>.*<\/td>/'; preg_match_all($data, $source, $data_matches); var_dump($data_matches); 上記、var_dumpの出力内容は(何故か二次元配列になってしまうんですが)、 array(1) { [0]=> array(80) { [0]=> string(72) "<td class="c"> hogehoge </td>" [1]=> string(21) "<td class="c">hogehoge</td>" [2]=> string(27) "<td>hogehoge</td>" [3]=> string(9) "<td>hogehoge</td>" [4]=> string(21) "<td class="c">hogehoge</td>" [5]=> string(9) "<td>hogehoge</td>" 上記の様に、欲しかったhogehogeの情報は取れているんですが、 <td class="c"></td>、<td></td>が邪魔です。。。 '/<td class="c">\s*.*\s*<\/td>|<td>.*<\/td>/'; 上記の正規表現は、hogehogeの場所を突き止めるのに必要だと思うんですが、 hogehogeのみ抽出したくて・・・。 $re = str_replace('<td class="c">', "", $data_matches); var_dump($re); 例えば上記の様にしても、<td class="c">が消えてくれません。。。 質問 1、何故、二次元配列になってしまうんでしょうか?問題ないのでしょうか?出来れば普通の配列にしたいんですが・・・。 2、どうすればhogehogeの場所を突き止め、そしてさらにhogehogeのみの情報を抽出出来るでしょうか?
↧