PHP提取Json当中的几个数据!50分求解答 高手来帮忙下!
网址例如: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
不知道怎么实现,本人新手,不太懂 百度了半天!
回复讨论(解决方案)
$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>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
