PHP提取Json当中的几个数据!50分求解答 高手来帮忙下!

php中文网
发布: 2016-06-23 13:47:03
原创
1260人浏览过

网址例如:http://123456.com/Ashx/actForm.ashx?action=addorder&gameid=65&num=10&realname=小梦&UserEmail=xiaomeng@qq.com&SearchPass=123654
提交以后的显示是 {"types":"OK","msg":"17961_14102404200616788"} 
我想用PHP直接调用出 _ 以后的数字 14102404200616788   
不知道怎么实现,本人新手,不太懂  百度了半天!

AI帮个忙
AI帮个忙

多功能AI小工具,帮你快速生成周报、日报、邮、简历等

AI帮个忙 55
查看详情 AI帮个忙

回复讨论(解决方案)

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


简洁,但是不能直接在后面加[1]

//$result = file_get_contents('http://123456.com/Ashx/actForm.ashx?action=addorder&gameid=65&num=10&realname=小梦&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"}     但是 他每次这个 生成 都不一样哇 !!! 

例如  
 {"types":"OK","msg":"17961_14102404200616788"}
 {"types":"OK","msg":"17962_14102453453453453"}
 {"types":"OK","msg":"17963_14102534534534535"}
 {"types":"OK","msg":"17964_14102534534534534"}
打开一次 他生成一次哇!

每次不一样有什么问题呢,处理方法都一样。

 $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).'<br>';}function getdata($str){    $data = json_decode($str, true);    list($id, $timestamp) = explode('_', $data['msg']);    return $timestamp;}
登录后复制


14102404200616788
14102453453453453
14102534534534535
14102534534534534

  现在调用出来了  接下来  要怎么把 14102404200616788 Json 调用到 JS那边去 例如别人网站 显示 

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>在线页面</title></head><body><div>正在跳转页面... ...</div></body></html><script>location.href='http://123456789.com/dopay/alipaydirect/do.aspx?orderid=14102422381915240'</script>
登录后复制

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号