Matrixkid Posted December 11, 2009 Share Posted December 11, 2009 Hey guys Ive been trying for a couple hours now to parse a data string but Im having no luck. I have the following: [ "\x3cdiv class=\"medium-content-below-item\"\x3e\n \x3cdiv class=\"desc\"\x3e\n \x3ch3 class=\"medium-content-below-item-title\"\x3e\x3ca class=\"title_link\" href=\"music/albums/1633820\"\x3e\n \x3cspan \x3eEmpire State Of Mind\x3c/span\x3e\n \x3c/a\x3e\x3c/h3\x3e\n \n \x3ca href=\"music/artists/195154/jay-z\"\x3e\n \x3cdiv class=\"medium-content-below-item-subtitle\"\x3eJay-z\x3c/div\x3e\n \x3c/a\x3e\n \n \x3cdiv class=\"medium-content-below-item-time\"\x3e10:32pm\x3c/div\x3e\n \n \n \x3c/div\x3e\n\x3c/div\x3e\n" ] Ive tried preg_replace, str_replace and nothing works. if i try using ">" or "<" it doesnt replace, nor does "\x3c" or "\x3e" In the end, im looking to just replace everything so im left with Empire State of Mind - Jay-z - 10:32pm If someone could help me just getting a str_replace or something like that to work that would be great. Thanks MK Link to comment https://forums.phpfreaks.com/topic/184731-decoded-string/ Share on other sites More sharing options...
rajivgonsalves Posted December 11, 2009 Share Posted December 11, 2009 something like this ? <?php $str = "\x3cdiv class=\"medium-content-below-item\"\x3e\n \x3cdiv class=\"desc\"\x3e\n \x3ch3 class=\"medium-content-below-item-title\"\x3e\x3ca class=\"title_link\" href=\"music/albums/1633820\"\x3e\n \x3cspan \x3eEmpire State Of Mind\x3c/span\x3e\n \x3c/a\x3e\x3c/h3\x3e\n \n \x3ca href=\"music/artists/195154/jay-z\"\x3e\n \x3cdiv class=\"medium-content-below-item-subtitle\"\x3eJay-z\x3c/div\x3e\n \x3c/a\x3e\n \n \x3cdiv class=\"medium-content-below-item-time\"\x3e10:32pm\x3c/div\x3e\n \n \n \x3c/div\x3e\n\x3c/div\x3e\n"; echo strip_tags(html_entity_decode($str)); ?> Link to comment https://forums.phpfreaks.com/topic/184731-decoded-string/#findComment-975208 Share on other sites More sharing options...
Matrixkid Posted December 11, 2009 Author Share Posted December 11, 2009 For me it shoots out the exact same thing. Looks like its the square brackets messing things up. thanks MK Link to comment https://forums.phpfreaks.com/topic/184731-decoded-string/#findComment-975209 Share on other sites More sharing options...
rajivgonsalves Posted December 11, 2009 Share Posted December 11, 2009 can you provide the code your using ? Link to comment https://forums.phpfreaks.com/topic/184731-decoded-string/#findComment-975210 Share on other sites More sharing options...
Matrixkid Posted December 11, 2009 Author Share Posted December 11, 2009 yep, here it is: $html = '[ "\x3cdiv class=\"medium-content-below-item\"\x3e\n \x3cdiv class=\"desc\"\x3e\n \x3ch3 class=\"medium-content-below-item-title\"\x3e\x3ca class=\"title_link\" href=\"music/albums/1633820\"\x3e\n \x3cspan \x3eEmpire State Of Mind\x3c/span\x3e\n \x3c/a\x3e\x3c/h3\x3e\n \n \x3ca href=\"music/artists/195154/jay-z\"\x3e\n \x3cdiv class=\"medium-content-below-item-subtitle\"\x3eJay-z\x3c/div\x3e\n \x3c/a\x3e\n \n \x3cdiv class=\"medium-content-below-item-time\"\x3e10:32pm\x3c/div\x3e\n \n \n \x3c/div\x3e\n\x3c/div\x3e\n" ]'; $string = str_replace("]","",$html); $string = str_replace("[","",$string); echo strip_tags(html_entity_decode($string)); Link to comment https://forums.phpfreaks.com/topic/184731-decoded-string/#findComment-975212 Share on other sites More sharing options...
rajivgonsalves Posted December 11, 2009 Share Posted December 11, 2009 your $html string should be in double quotes Link to comment https://forums.phpfreaks.com/topic/184731-decoded-string/#findComment-975215 Share on other sites More sharing options...
Matrixkid Posted December 11, 2009 Author Share Posted December 11, 2009 Oh I see, i have to replace the bracket and the double quote. Thanks for the help, its much appreciated! Link to comment https://forums.phpfreaks.com/topic/184731-decoded-string/#findComment-975216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.