jamesxg1 Posted October 6, 2009 Share Posted October 6, 2009 Hiya peeps, Just wondering where i start really. I want to make a page where i can input html into a textarea and print every div id value. Eg. <div id="hello"> Page prints 'hello'. Where do i start ?, Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/ Share on other sites More sharing options...
Mchl Posted October 6, 2009 Share Posted October 6, 2009 Probably looking at preg_match_all Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931713 Share on other sites More sharing options...
jamesxg1 Posted October 6, 2009 Author Share Posted October 6, 2009 Cheers mate, That look's rather complicated to use, Would you point me in the right direction on how to use this please mate ?, Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931715 Share on other sites More sharing options...
jamesxg1 Posted October 6, 2009 Author Share Posted October 6, 2009 Anyone ?, Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931726 Share on other sites More sharing options...
Mchl Posted October 6, 2009 Share Posted October 6, 2009 Here's a tutorial about regular expressions http://www.regular-expressions.info/ Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931728 Share on other sites More sharing options...
attock Posted October 6, 2009 Share Posted October 6, 2009 if you dont like preg_match then you might wana try sumthing like $arr = split('id="', $html); echo substr($arr[1],0,-1); using regular expressions would be the correct way of doing it. Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931732 Share on other sites More sharing options...
Mchl Posted October 6, 2009 Share Posted October 6, 2009 That's assuming there's only an opening div tag in html code, and it contains id property as the last one. Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931735 Share on other sites More sharing options...
.josh Posted October 6, 2009 Share Posted October 6, 2009 $subject = "content to match here"; preg_match_all('~<div[^>]*id\s?=\s?["\']([^"\']+)~i',$subject,$matches); print_r($matches[1]); or as an alternative, you might want to consider using DOM Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931749 Share on other sites More sharing options...
jamesxg1 Posted October 6, 2009 Author Share Posted October 6, 2009 @CV; Cheers mate worked!. Many thanks, James. Quote Link to comment https://forums.phpfreaks.com/topic/176722-solved-php-how-do-i-strip-html-to-show-all-div-id-names/#findComment-931757 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.