alex.nenov Posted March 27, 2007 Share Posted March 27, 2007 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 More sharing options...
ted_chou12 Posted March 27, 2007 Share Posted March 27, 2007 will this string length always be the same? 0000qPANYJmsrxP4GdSzZtPI7h9, 27 characters? Link to comment https://forums.phpfreaks.com/topic/44477-str_replace-problem/#findComment-216026 Share on other sites More sharing options...
Jenk Posted March 27, 2007 Share Posted March 27, 2007 Why don't you just link their site instead of stealing content? Link to comment https://forums.phpfreaks.com/topic/44477-str_replace-problem/#findComment-216028 Share on other sites More sharing options...
ted_chou12 Posted March 27, 2007 Share Posted March 27, 2007 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 More sharing options...
alex.nenov Posted March 28, 2007 Author Share Posted March 28, 2007 I try to put a public content ( about bus traffic and stations in our country ) from official transport site to my travel site. The problem is only this string that every time is different but 28 chars long. I have to replace it with "" but I can't Link to comment https://forums.phpfreaks.com/topic/44477-str_replace-problem/#findComment-216716 Share on other sites More sharing options...
per1os Posted March 28, 2007 Share Posted March 28, 2007 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 More sharing options...
alex.nenov Posted March 29, 2007 Author Share Posted March 29, 2007 Thank you Link to comment https://forums.phpfreaks.com/topic/44477-str_replace-problem/#findComment-217657 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.