Php 从字符串中获取特定数据
我想从该脚本中以字符串形式获取以下数据“PHPSESSID”:Php 从字符串中获取特定数据,php,string,Php,String,我想从该脚本中以字符串形式获取以下数据“PHPSESSID”: <?php file_get_contents('https://www.bedandbreakfast.nl/?page=ajaxcb&do=updateBookingIntent&arrival=2015-08-22&departure=2015-08-23&src=booking_arrival'); $cookies = array(); foreach ($http_resp
<?php
file_get_contents('https://www.bedandbreakfast.nl/?page=ajaxcb&do=updateBookingIntent&arrival=2015-08-22&departure=2015-08-23&src=booking_arrival');
$cookies = array();
foreach ($http_response_header as $hdr) {
if (preg_match('/^Set-Cookie:\s*([^;]+)/', $hdr, $matches)) {
parse_str($matches[1], $tmp);
$cookies += $tmp;
}
}
print_r($cookies);
?>
这一个有效:
file_get_contents('https://www.bedandbreakfast.nl/?page=ajaxcb&do=updateBookingIntent&arrival=2015-08-22&departure=2015-08-23&src=booking_arrival');
foreach ($http_response_header as $header) {
if (substr($header, 0, 21) == 'Set-Cookie: PHPSESSID') {
preg_match('/=([a-z0-9]+);/', $header, $matches);
$sessionId = $matches[1];
echo $sessionId;
}
}
作为链接问题的副本重新打开。字符串:
$data=“Array([PHPSESSID]=>infodata)”代码>数组:$data=array(“PHPSESSID”=>“infodata”)
为以下问题提供一些答案:如果您想要访问数组,那么如果您确实有一个数组可以开始,这将非常有用。完整的代码现在已上载;)@里泽尔123:你不能。这就是我说“同意”的原因。OP是个笨蛋。
file_get_contents('https://www.bedandbreakfast.nl/?page=ajaxcb&do=updateBookingIntent&arrival=2015-08-22&departure=2015-08-23&src=booking_arrival');
foreach ($http_response_header as $header) {
if (substr($header, 0, 21) == 'Set-Cookie: PHPSESSID') {
preg_match('/=([a-z0-9]+);/', $header, $matches);
$sessionId = $matches[1];
echo $sessionId;
}
}