fer0an Posted July 21, 2010 Share Posted July 21, 2010 hello I've some code and I want remove all of them except URL anyone can help me? http://website.ws/RBR.Magazine.Nr.07.Anno.03.html' type='button_count'></a> </div> <div class='text'> <div class="image"><a href="http://website.ws/1428545" target="_blank" rel="nofollow"><img src="http://website/41/cc/0015cc41_medium.jpeg" id="external_img_1428545"/></a></div><br/> <div class="center"><b>RBR Magazine nr.07 Luglio 2010</b><br/> Lang: Italian | 38 pag | PDF | 11,2 Mb</div><br/> <br/> <br/> <br/> <div class="center"><b>Megaupload</b><br/> <a href="http://www.megaupload.com/?d=FHAHPG9Q" target="_blank" rel="nofollow">http://www.megaupload.com/?d=FHAHPG9Q</a><br/> <b>EasyShare</b><br/> <a href="http://www.easy-share.com/1911385492/RBR%20Magazine%20Nr.07%20Anno%203.pdf" target="_blank" rel="nofollow">http://www.easy-share.com/1911385492/RBR Magazine Nr.07 Anno 3.pdf</a><br/> <br/> <b><a href="http://website.ws/blogs/MGripi" target="_blank" rel="nofollow">My Blog</a><br/> <br/> <br/> Buona Giornata </b></div> </div> <table class='file-express' width='100%'> <tr> <td style='text-align: left; color: #B2AC94; font-size: 3'>ADVERTISING Link to comment https://forums.phpfreaks.com/topic/208392-select-some-text/ Share on other sites More sharing options...
timvdalen Posted July 21, 2010 Share Posted July 21, 2010 Use strpos() to find the ' and then use substr($string, 0, $strposofstroph) to find the URL Good luck Link to comment https://forums.phpfreaks.com/topic/208392-select-some-text/#findComment-1088992 Share on other sites More sharing options...
fer0an Posted July 21, 2010 Author Share Posted July 21, 2010 thank you for reply. but I didn't know about this code. can you please type exact code that can I use it? thank you Link to comment https://forums.phpfreaks.com/topic/208392-select-some-text/#findComment-1089008 Share on other sites More sharing options...
timvdalen Posted July 22, 2010 Share Posted July 22, 2010 thank you for reply. but I didn't know about this code. can you please type exact code that can I use it? thank you Yeah, I'm not gonna do that, or else you won't learn from it. strpos() get's the position of a string within a string. So if you do: $string = "Hello, this is a lovely day isn't it?"; echo strpos($string, "'"); It would output 31. You then know that the ' is on position 31. substr() get's a part of another string. You want to get everything up to the ' in your code right? Only the http://website.ws/RBR.Magazine.Nr.07.Anno.03.html part. I want to get "Hello, this is a lovely day isn" from my string, so I would do: $string = "Hello, this is a lovely day isn't it?"; $startposition = 0; //I want to start getting the new string at position 0, aka the beginning of the string $endposition = strpos($string, "'"); //I want to get the part of the string up to the position of ' $newstring = substr($string, $startposition, $endposition); And that's all. Good luck. PS. If I misunderstood you and you want to get ALL URLS from that string, please say so, as it would be easier and quicker to use regex for that. Link to comment https://forums.phpfreaks.com/topic/208392-select-some-text/#findComment-1089459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.