简体   繁体   English

数组过滤 - php

[英]array filtering - php

echo $cookie[4];

Result: 结果:

#HttpOnly_bacohuracm FALSE / TRUE 0 PHPSESSID 3A8DB8BE067954EE327A56F7F8D8B19C 

i wanna delete this part: 我想删除这部分:

#HttpOnly_bacohuracm FALSE / TRUE 0 PHPSESSID 

and wanna get only this part: 只想得到这一部分:

3A8DB8BE067954EE327A56F7F8D8B19C 

i tried preg_match, it has given a null result. 我试过preg_match,它给出了一个null结果。 i tried some other ways, and gotten same null result and still couldn't figure out how i can do this job with php.. please give me some advice 我尝试了一些其他的方法,得到了相同的null结果,仍然无法弄清楚我怎么能用PHP做这个工作..请给我一些建议

foreach($cookie as $value)
    echo substr($value, strpos($value, 'PHPSESSID')+10);

Would work 会工作

To return only what you're looking for: 只返回您要查找的内容:

$source = "#HttpOnly_bacohuracm FALSE / TRUE 0 PHPSESSID 3A8DB8BE067954EE327A56F7F8D8B19C";
preg_match("/PHPSESSID (\w+)$/", $source, $matches);
print $matches[1];

If this still returns null, is error text being suppressed? 如果仍然返回null,是否会抑制错误文本? Is there anything related in the logs? 日志中有相关内容吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM