我尝试从字符串中删除所有<p>
,但对我而言仅适用于foreach中的第一个元素。
$fullstring = '<ul>';
foreach ($item['children'] as $key => $sub_item) {
$nextElement = str_replace(array("<p>", "</p>"), array("", ""), $sub_item['content']['content']);
$fullstring .= '<li>' . $nextElement . '</li>';
}
$fullstring .= '</ul>';
得到(来自日志)$sub_item
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>The [X] is paid for all of the Products and no other amounts are owed by the [Y] to the [X] in respect of other Products supplied by the [X].<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>The [Y] sells the Products in accordance with this agreement in which case ownership of the Products will pass to the [Y] immediately before the Products are delivered to the [Y]'s customer.<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>they become the [Y]'s property; or<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>they are attached to or incorporated in other Products; or<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>they are delivered to a purchaser from the [Y].<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>If the [Y] sells the Products, the [Y] shall hold the proceeds of sale on trust for the [X] in a separate bank account.<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>The [X] may trace the proceeds of sale that the [Y] receives into any bank or other account which the [Y] maintains.<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>If the [Y] sells the Products, the [X] may, by written demand, require the [Y] to assign to the [X] the [Y]'s rights to recover the price from its customer.<\/span><\/p>","numbering":""},"children":[]}
[2020-04-06 11:05:12] local.INFO: Receiving response:{"content":{"content":"<p><span>The [Y] must not assign to any other person any rights arising from a sale of the Products without the [X]'s written consent.<\/span><\/p>","numbering":""},"children":[]}