ShivaGupta Posted October 25, 2013 Share Posted October 25, 2013 Want to explode A from B Tryed myself but no luck plz help A PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV B u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}] Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/ Share on other sites More sharing options...
requinix Posted October 25, 2013 Share Posted October 25, 2013 That looks like JSON. json_decode Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455440 Share on other sites More sharing options...
ShivaGupta Posted October 25, 2013 Author Share Posted October 25, 2013 That looks like JSON. json_decode $json = 'u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}]'; var_dump(json_decode($json)); var_dump(json_decode($json, true)); I AM GETING NULL NULL Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455443 Share on other sites More sharing options...
Ch0cu3r Posted October 25, 2013 Share Posted October 25, 2013 Where is this 'u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}] snippet of code from? You need to make it valid json syntax in order to decode it with json_decode You can do $json = '[{"u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}]'; $data = json_decode($json, true); echo $data[0]['u']; Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455444 Share on other sites More sharing options...
ShivaGupta Posted October 25, 2013 Author Share Posted October 25, 2013 Where is this 'u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}] snippet of code from? You need to make it valid json syntax in order to decode it with json_decode You can do $json = '[{"u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"}]'; $data = json_decode($json, true); echo $data[0]['u']; here is my code if ( preg_match("/u\"\.*?)}/i", $html,$matches) ) { $user = $matches[0]; echo "<font color=green><b>".$user."</b><br></font>"; } else { echo "A match was not found."; } //returned u":"PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV"} //need only PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455445 Share on other sites More sharing options...
Ch0cu3r Posted October 25, 2013 Share Posted October 25, 2013 In that case use $user = $matches[1]; Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455446 Share on other sites More sharing options...
ShivaGupta Posted October 25, 2013 Author Share Posted October 25, 2013 In that case use $user = $matches[1]; with this $user = $matches[1]; i am geting "PB4CwyDzE6FnnqDrnEoEPWIuC9_uWV" //how to remoove " from string ? Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455449 Share on other sites More sharing options...
Ch0cu3r Posted October 25, 2013 Share Posted October 25, 2013 you can use trim $user = trim($matches[1], '"'); Or change your regex to only match the text within the quotes if ( preg_match('/u":"([a-z0-9_]+)"}/i', $html,$matches) ) Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455452 Share on other sites More sharing options...
ShivaGupta Posted October 25, 2013 Author Share Posted October 25, 2013 you can use trim $user = trim($matches[1], '"'); Or change your regex to only match the text within the quotes if ( preg_match('/u":"([a-z0-9_]+)"}/i', $html,$matches) ) with this $user = trim($matches[1], '"'); my provlem solved...... "Thanks a lot" Link to comment https://forums.phpfreaks.com/topic/283283-a-little-help-plz/#findComment-1455455 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.