Jump to content

move a string to a different location


Guest

Recommended Posts

I am displaying an external page on my website with file_get_contents() so i have no control over the text. But i need to move a string to a different location  in the page.

I have tried with preg_replace but it's not working. I think it's because the distance between the wildcard delimiter is too long.

 

After moving the string, i also need to add <img> tags around it

 

My page looks like this :

 

(lots of html code here)
<input type="hidden" name="product" value="20842421" />
(lots of html code here)
<div class="articleSize">
(lots of html code here)
<input type="hidden" name="product" value="20842422" />
(lots of html code here)
<div class="articleSize">
(lots of html code here)

 

The result i am expecting would be :

 

(lots of html code here)
<input type="hidden" name="product" value="20842421" />
(lots of html code here)
<img src="20842421.gif">
<div class="articleSize">
(lots of html code here)
<input type="hidden" name="product" value="20842422" />
(lots of html code here)
<img src="20842422.gif">
<div class="articleSize">
(lots of html code here)

 

I have over 60 different different matches to move on this page

 

Any help would be appreciated

Link to comment
https://forums.phpfreaks.com/topic/266316-move-a-string-to-a-different-location/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.