English 中文(简体)
光盘的具体印刷部分,按网址分列
原标题:Print specific part from an URL by php

我只想用乌尔里语印刷一部分,比如说,如果要回答的话,就象这样:

https://tvoauth.zapi.com/?client=zapi-web-1&session=XRpC8tmn2_VUz6temt_j19BIGymiYyd5ZOLoWtp1H5U&scopes=false&redirect=https%3A%2F%2Ftv.zapi.com

我只想印刷这一部分:

XRpC8tmn2_VUz6temt_j19BIGymiYyd5ZOLoWtp1H5U

我曾试图用这样的文字:

$string=$headers[ location ][0];

$substring = substr($string, strpos($string,  = ) + 1);
// Use substr() again to get the part of the string before the semicolon
$final_string = substr($substring, 0, strpos($substring,  ; ));
   file_put_contents("xxx", $final_string);
   $xtoken = file_get_contents("xxx");

but it s doesn t print nothing to my file xxx

但是,如果我这样说的话,这只是:

$string=$headers[ location ][0];

   file_put_contents("xxx", $string);
   $xtoken = file_get_contents("xxx");

如前所述,它全线印刷。

我希望,我发现正确的指南能够选择和复制;只印刷我想要的那部分内容。

感谢您。

问题回答

或许,parse_url ,然后 rel=“nofollow noretinger”>parse_str 如果没有需要,可帮助?

例如:

<?php

$url =  https://tvoauth.zapi.com/?client=zapi-web-1&session=XRpC8tmn2_VUz6temt_j19BIGymiYyd5ZOLoWtp1H5U&scopes=false&redirect=https%3A%2F%2Ftv.zapi.com ;

$parsed = parse_url($url);

var_dump($parsed);

$output = [];

parse_str($parsed[ query ], $output);

var_dump($output);

echo $output[ session ];

产出:

array(4) {
  ["scheme"]=>
  string(5) "https"
  ["host"]=>
  string(16) "tvoauth.zapi.com"
  ["path"]=>
  string(1) "/"
  ["query"]=>
  string(117) "client=zapi-web-1&session=XRpC8tmn2_VUz6temt_j19BIGymiYyd5ZOLoWtp1H5U&scopes=false&redirect=https%3A%2F%2Ftv.zapi.com"
}

array(4) {
  ["client"]=>
  string(10) "zapi-web-1"
  ["session"]=>
  string(43) "XRpC8tmn2_VUz6temt_j19BIGymiYyd5ZOLoWtp1H5U"
  ["scopes"]=>
  string(5) "false"
  ["redirect"]=>
  string(19) "https://tv.zapi.com"
}

XRpC8tmn2_VUz6temt_j19BIGymiYyd5ZOLoWtp1H5U

?


EDIT: from the comment about the file:
(will not be able to write to a file in the online example)

之后,如果希望有不同的名称,可登录file_put_contents("xxx”)、$output[ session]、或任何人希望打$output





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签