Jump to content

Decoded String


Matrixkid

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.