Jump to content

A Little help plz.


ShivaGupta

Recommended Posts

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

 

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

 

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

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.