Jump to content

str_replace problem


alex.nenov

Recommended Posts

Hello,

 

i have a little problem. I grab the code from one page. After that i start a script that make str_raplace() to all junk content. I do it in 90% but.... some images and link have strings with user session. Example:

 

<td><img src=\"images/shim.gif\"><a href=\"searchDeparturesSimple.jsp;jsessionid=0000qPANYJmsrxP4GdSzZtPI7h9:-1?l=0\"><img src=\"images/flag.gif\" border=\"0\" width=\"21\" height=\"13\"></a></td>

 

this string 0000qPANYJmsrxP4GdSzZtPI7h9 is different every time when i access the page. So i can not replace this string. Can you help mi. I read many examples and tutorials with regular expresions bug I can't understand how to do this.

 

Thank you :)

Link to comment
https://forums.phpfreaks.com/topic/44477-str_replace-problem/
Share on other sites

Hello,

 

i have a little problem. I grab the code from one page. After that i start a script that make str_raplace() to all junk content. I do it in 90% but.... some images and link have strings with user session. Example:

 

<td><img src=\"images/shim.gif\"><a href=\"searchDeparturesSimple.jsp;jsessionid=0000qPANYJmsrxP4GdSzZtPI7h9:-1?l=0\"><img src=\"images/flag.gif\" border=\"0\" width=\"21\" height=\"13\"></a></td>

 

this string 0000qPANYJmsrxP4GdSzZtPI7h9 is different every time when i access the page. So i can not replace this string. Can you help mi. I read many examples and tutorials with regular expresions bug I can't understand how to do this.

 

Thank you :)

That looks to me that (s)he is just trying to link in order to bring traffic to the targeted site, and codes like 0000qPANYJmsrxP4GdSzZtPI7h9 dont look very useful to me at all.

Ted

Link to comment
https://forums.phpfreaks.com/topic/44477-str_replace-problem/#findComment-216030
Share on other sites

lol this is more complicated than just str_replace my good fellow:

 

<?php
$input = "<td><img src=\"images/shim.gif\"><a href=\"searchDeparturesSimple.jsp;jsessionid=0000qPANYJmsrxP4GdSzZtPI7h9:-1?l=0\"><img src=\"images/flag.gif\" border=\"0\" width=\"21\" height=\"13\"></a></td>";

list(,$img,$url,$img2) = split("><", $input);

list(,$img) = split("src=", $img); // should now be images.shim.gif w/quotes
list(,$url) = split("href=", $url); // should now be the url. w/quote
list(,$img2) =  split("src=", $img2);
list($img2) = split(" border", $img2); // should be image 2 w/quote

//Now you have everything into strings and you can rebuild the link but if you want that session id do this. also
list(,$sessid) = split("jsessionid=", $url);
list($sessid) = split("\?", $sessid);

print $img . '<br />' . $url . '<br />' . $img2 . '<br />' . $sessid;

?>

Link to comment
https://forums.phpfreaks.com/topic/44477-str_replace-problem/#findComment-216745
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.