PHP extracts several data from JSON! 50 points to solve the expert to help!

Source: Internet
Author: User
Web site For example: Http://123456.com/Ashx/actForm.ashx?action=addorder&gameid=65&num=10&realname= small Dream & useremail=xiaomeng@qq.com&searchpass=123654
The display after submission is {"Types": "OK", "MSG": "17961_14102404200616788"}
I want to use PHP directly call out _ after the number 14102404200616788
Do not know how to achieve, I novice, do not quite understand Baidu a half-day!


Reply to discussion (solution)

$s = ' {' types ': ' OK ', ' msg ': ' 17961_14102404200616788 '} ';
Echo Explode (' _ ', Json_decode ($s)->msg) [1];

$s = ' {' types ': ' OK ', ' msg ': ' 17961_14102404200616788 '} ';
Echo Explode (' _ ', Json_decode ($s)->msg) [1];


Concise, but not directly in the back add [1]

$result = file_get_contents (' http://123456.com/ashx/actform.ashx?action=addorder&gameid=65&num=10& Realname= small Dream &useremail=xiaomeng@qq.com&searchpass=123654 '); $result = ' {' Types ': "OK", "MSG": "17961_ 14102404200616788 "}"; $json = Json_decode ($result, true); $id = Explode (' _ ', $json [' msg ']); echo $id [1];

{"Types": "OK", "MSG": "17961_14102404200616788"} but every time this generation is different WOW!!!

For example
{"Types": "OK", "MSG": "17961_14102404200616788"}
{"Types": "OK", "MSG": "17962_14102453453453453"}
{"Types": "OK", "MSG": "17963_14102534534534535"}
{"Types": "OK", "MSG": "17964_14102534534534534"}
Open it once and he generates it once WOW!

Every time there is a different problem, the treatment method is the same.

$result = Array (     ' {' Types ': ' OK ', ' msg ': ' 17961_14102404200616788 '} ',     ' {' Types ': ' OK ', ' msg ': ' 17962_ 14102453453453453 "} ',     ' {" Types ":" OK "," MSG ":" 17963_14102534534534535 "} ',     ' {" Types ":" OK "," MSG ":" 17964_ 14102534534534534 "}"), foreach ($result as $v) {    echo GetData ($v). '
';} function GetData ($str) { $data = Json_decode ($str, true); List ($id, $timestamp) = Explode (' _ ', $data [' msg ']); return $timestamp;}


14102404200616788
14102453453453453
14102534534534535
14102534534534534

Now call out how to put 14102404200616788 Json call to JS over there, for example, someone else's site display

 
  Online pageJumping page ...
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.