Split the string by "|"
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'] );
精彩评论