-2

可能重复:
如何使用 PHP 解析和处理 HTML?

我有以下 HTML:

<Text><strong>Cancellation</strong>
A cancellation is free of charge possible until 6PM on arrival day. With later    cancellation or no arrivals without previous cancellation the hotel is justified to place 90% of the booked achievements (excl. breakfast) in calculation whereby the amount at a value of USD 500.00 is not exceeded.
<strong>Check-in time</strong>
Starting from 15:00
<strong>Check-out time</strong>
Until 12:00
<strong>Guarantee</strong>
No guarantee required.</Text>

我想解析它并存储在一个数组中,例如:

array(
 'Cancelation'    => 'A cancellation is free of charge possible until 6PM on arrival day. With later    cancellation or no arrivals without previous cancellation the hotel is justified to place 90% of the booked achievements (excl. breakfast) in calculation whereby the amount at a value of USD 500.00 is not exceeded.',
 'Check-in time'  => 'Starting from 15:00',
 'Check-out time' => 'Until 12:00',
 'Guarantee'      => 'No guarantee required.'
);

感谢您提前提供提示。

4

2 回答 2

0

阅读教程,无需使用饥饿的正则表达式引擎。

于 2012-10-18T08:47:48.137 回答
-1

有效的HTML 添加到DOMElement对象中。有了它,您可以选择孩子并将他们的 HTML/文本提取到变量中。

文档: http: //php.net/manual/en/class.domelement.php

于 2012-10-18T08:43:49.720 回答