开发者

Split the string by "|"

开发者 https://www.devze.com 2023-03-08 10:50 出处:网络
Hi I am trying to over come a small is开发者_高级运维sue that I am getting, it seems it will not allow me to split a Cookie

Hi I am trying to over come a small is开发者_高级运维sue that I am getting, it seems it will not allow me to split a Cookie

basicly I have a cookie stored that has session|userid

I want to be able to get the session part of that cookie

I have tried everything I now, but seems nothing wants to work.

$this->stringer = $_COOKIE["_now_Session"];
$array=preg_split('@|@',$this->stringer); 


There is no need for preg_split here, simply use explode:

$aData = explode("|", $_COOKIE['_now_Session']);
echo $aData[0]; // session
echo $aData[1]; // userid


$array=explode('|',$this->stringer); 

Manual:
explode


$array=preg_split('@|@', $this->stringer);

Why use preg_split in the first place? I'd use explode for this, really:

<?php
list( $session, $userid ) = explode( '|' , $_COOKIE['_now_Session'] );
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号