I am reading the contents of some files with file_get_contents
the files contain a series of links and images. Ideally, they should all look like this.
The link and image will always be the same matching 8 digit numbers like this...
<a href= /item/33333333 >
<img src="https://www.example.com/33333333.gif"></a>
<a href= /item/12345678 >
<img src="https://www.example.com/12345678.gif"></a>
有时,错误形象将显示,而不是 g。 此处注明该错误的档案内容......
<a href= /item/77778888 >
<img src="/images/default.svg"></a>
<a href= /item/33333333 >
<img src="https://www.example.com/33333333.gif"></a>
<a href= /item/12345678 >
<img src="https://www.example.com/12345678.gif"></a>
<a href= /item/22225555 >
<img src="/images/default.svg"></a>
因此,我需要最终结果。
<a href= /item/77778888 >
<img src="https://www.example.com/77778888.gif"></a>
<a href= /item/33333333 >
<img src="https://www.example.com/33333333.gif"></a>
<a href= /item/12345678 >
<img src="https://www.example.com/12345678.gif"></a>
<a href= /item/22225555 >
<img src="https://www.example.com/22225555.gif"></a>
I m not sure how to go about figuring out what 8 digit number appears before each default.svg
and replacing it. Would we have to look back a certain number of characters each time default.svg
appears to get that number?
增 编