richiec Posted July 6, 2007 Share Posted July 6, 2007 is there anyway to use file_get_contents to search for a text in a websites source code and then when it finds the text stated it displays an image? Thanks Rich. Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/ Share on other sites More sharing options...
teng84 Posted July 6, 2007 Share Posted July 6, 2007 yes bro but only the html Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291612 Share on other sites More sharing options...
richiec Posted July 6, 2007 Author Share Posted July 6, 2007 Yes thats all i need it to search for, could you give me an example of how to do that please. --- Wait are you saying it will only display the html of the image and not display the actual image? Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291614 Share on other sites More sharing options...
richiec Posted July 7, 2007 Author Share Posted July 7, 2007 can noone help? Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291714 Share on other sites More sharing options...
teng84 Posted July 7, 2007 Share Posted July 7, 2007 use the file_get_contents Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291715 Share on other sites More sharing options...
Barand Posted July 7, 2007 Share Posted July 7, 2007 use str_replace <?php $str = 'Sample [image_here] text'; // result of file_get_contents echo str_replace ('[image_here]', '<img src="myimage.gif">', $str); /** * multiple images sample */ $s = array ( '[image1]', '[image2]', '[image3]' ); $r = array ( '<img src="imagex.gif">', '<img src="imagey.gif">', '<img src="imagez.gif">' ); $str = 'Sample [image1] text [image2] with more [image3] images'; // result of file_get_contents echo str_replace ($s, $r, $str); ?> Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291839 Share on other sites More sharing options...
richiec Posted July 7, 2007 Author Share Posted July 7, 2007 that didnt work it didnt replace the text with an image it just displayed the images then the text... any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291892 Share on other sites More sharing options...
Yesideez Posted July 7, 2007 Share Posted July 7, 2007 Care to show an example piece of text with an example of what you want it to change to? Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291894 Share on other sites More sharing options...
Yesideez Posted July 7, 2007 Share Posted July 7, 2007 you thinking of ripping stuff like this? http://www.pictureinthesky.net/utils/ripper.php Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291895 Share on other sites More sharing options...
richiec Posted July 7, 2007 Author Share Posted July 7, 2007 if you go here http://dksgfx.freehostia.com/FW/parsetest/profileparse.php put in DevilKnightSparda that will bring up the list of skills that i currently have cast on my account inside the table. Above the table is the skill images. i want to replace the text found from file_get_contents which pulls the text inside the table with the images. Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291896 Share on other sites More sharing options...
Yesideez Posted July 7, 2007 Share Posted July 7, 2007 Sorry but that is as clear as mud ??? Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291903 Share on other sites More sharing options...
richiec Posted July 7, 2007 Author Share Posted July 7, 2007 ok... let me try again.. this part gets the information about which skills are cast on the profile you search for... $url = 'http://sigil.outwar.com/profile.php?transnick='; if (isset($_POST['submit'])){ if (empty($_POST['cid'])){ $cid = ''; } else { $cid = '' . $_POST['cid']; } $file = file_get_contents($url . $cid); list($before, $after) = split("/images/skill_13.gif", $file); list($looting) = split("You steal", $after); list($before, $after) = split("/images/skill_46.gif", $file); list($wall) = split("Casting shield", $after); list($before, $after) = split("/images/skill_4.gif", $file); list($stealth) = split("Increases targets HP", $after); list($before, $after) = split("/images/skill_28.gif", $file); list($fort) = split("You receive +", $after); list($before, $after) = split("/images/skill_15.gif", $file); list($cop) = split("Reduces your damage taken", $after); list($before, $after) = split("/images/skill_7.gif", $file); list($bag) = split("Makes all your supplies invulnerable", $after); list($before, $after) = split("/images/skill_50.gif", $file); list($bfa) = split("You receive +", $after); list($before, $after) = split("/images/skill_3.gif", $file); list($emp) = split("Increases targets ATK", $after); list($before, $after) = split("/images/skill_9.gif", $file); list($lust) = split("Target receives +", $after); list($before, $after) = split("/images/skill_2952.gif", $file); list($no problem) = split("Reward buff for", $after); this part displays what skills it finds echo "<table border=\"1\"> <tr> <td width=\"188\"><b>$cid</b></td> <td width=\"1000\">$looting $wall $stealth $fort $cop $bag $bfa $emp $lust $no problem</td> </tr> "; what i want to do is replace where on the site it has: " hspace="2" width="25" height="25" ONMOUSEOVER="popup(event,' with the correct image of that skill Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291906 Share on other sites More sharing options...
Yesideez Posted July 7, 2007 Share Posted July 7, 2007 str_replace() is what you're looking to use here. http://www.php.net/str_replace That documents how to use it. Something like this I imagine: str_replace('" hspace="2" width="25" height="25" ONMOUSEOVER="popup(event,\'',$image,$data); Where: $image contains the link to the image $data hold the string containing the string you want to replace Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-291907 Share on other sites More sharing options...
richiec Posted July 8, 2007 Author Share Posted July 8, 2007 ok i did what you said but i still cant get it to work.. in adidtion to the code i showed before this is what i also have now.. $lootingimage = "http://sigil.outwar.com/images/skill_13.gif"; $data = 'hspace="2" width="25" height="25" ONMOUSEOVER="popup(event,' Then i have the example of what you told me.. str_replace('hspace="2" width="25" height="25" ONMOUSEOVER="popup(event,\'',$lootingimage,$data); and it gives me the following error... "Parse error: parse error, unexpected T_VARIABLE in /home/www/dksgfx.freehostia.com/FW/parsetest/profileparse.php on line 32" line 32 is $data = 'hspace="2" width="25" height="25" ONMOUSEOVER="popup(event,' any idea what im doing wrong :-s Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-292568 Share on other sites More sharing options...
Barand Posted July 8, 2007 Share Posted July 8, 2007 Opening and closing quotes don't balance, try str_replace('hspace="2" width="25" height="25" ONMOUSEOVER="popup(event,"',$lootingimage,$data); Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-292573 Share on other sites More sharing options...
richiec Posted July 8, 2007 Author Share Posted July 8, 2007 It still gives me the error: Parse error: parse error, unexpected T_VARIABLE in /home/www/dksgfx.freehostia.com/FW/parsetest/profileparse.php on line 32 line 32 is $data = 'hspace="2" width="25" height="25" ONMOUSEOVER="popup(event,"' :-s Quote Link to comment https://forums.phpfreaks.com/topic/58779-replace-text-with-an-image-help-please-x/#findComment-292580 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.