Jump to content

A Little help plz.


ShivaGupta
Go to solution Solved by Ch0cu3r,

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'];

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
Edited by ShivaGupta
Link to comment
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"

Edited by ShivaGupta
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.