Hi guy's!, can any one help me, how to extract all html link from a string. i have tried alot at best of my level but didn't get optimum result. regard's
Something you could try, it's a quick and dirty way to get it done: <? $linkcount = 0; $explode = explode("http://",$string); for ($round=1;$round< count($explode);$round++) { $temp = explode(" ",$explode[$round]); $links[$linkcount] = $temp[0]; $linkcount++; } print_r($links); // prints a list of the links Code (markup): That should work fine. I haven't tested it, so give it a run and let me know if it isn't working.
Use preg_match function. Here is the regex pattern that you can use: $linkPattern = '/<a[\s]+[^>]*?href[\s]?=[\s\"']+(.*?)[\"']+.*?>([^<]+|.*?)?<\/a>/is'; Amit
but dear friend Grunt when any user didn't provide http:// in that case this logic will not as i think.
True (Krishna) . . . samyak probably had a better code, it would grab based on <a href> links and not http://. Course, his wouldn't get any plain text URLs (those not actually put in a hyperlink), so it may depend on what content you are looking at. If all the links on the pages you use the code on will actually be hyperlinked (and not just have plain-text URLs) then samyak's code is the way to go.
Hi i am decode the string in html entities now string look like this. <p>I would like to introduce myself, my name is xyz and I am the<br />Director of Sales for the abc Marketing Group. One of my marketing<br />colleagues had informed me that you are interested in learning more about<br />our promotions, rewards and vacation incentive products.<a href=\"http://www.xyz.com\">http://www.xyz.com</a><br /><br /> <br /><br />abc remains the #1 finance incentive company in North America, offering<br />more variety and more product options. Odenza is unique in that we are a<br />full service travel incentive group with all the key services to ensure your<br />travel incentive needs are met. This includes our own marketing and graphic<br />design department at your service and most importantly, in-house travel<br />agents to fulfill travel requests from your customers receiving our travel<br />incentives.<a href=\"http://www.xyz.com\">http://www.xyz.com</a><br /><br /> <br /><br />We also provide small business products through our Fun Planet line of<br />incentives that can be purchased for as little as $10.00. You can buy as<br />little as 30 certificates to get started. These programs are ideal for thesmall<br />business looking to get an edge on their competition, and generate more<br />sales.<br /><br />Best regards,<br /> <br />abc<br />Director of Sales<br /><br />abc financeGROUP INC.<br />When Relationships Really Matter<br /><a href=\"http://www.xyz.com\">http://www.xyz.com</a></p> i am store this htmlentity in variable and using preg_match_all and pass three parameter into the preg_match_all function. after that when i am print array then it didn,t dispaly anything. Here is the out put Array ( [0] => Array ( ) [1] => Array ( ) [2] => Array ( ) ) please kindly help me