How to write the token value dwwewee in & quot; userasdasd; tokendwwewee; typeassdfs & quot; in php? I really don't want to write .. This does not seem to work. {code...} I want to retrieve the token value in the string "user = asdasd; token = dwwewee; type = assdfs" dwwewee,
How to Write php?
I really don't want to write ..
This does not seem to work either.
preg_match("/(token=)(.*?)(;|$)/i","user=asdasd; token=dwwewee; type=assdfs", $matches);foreach ($matches as $m){ echo $m;echo "
";}
Reply content:
I want to retrieve the token value in the string "user = asdasd; token = dwwewee; type = assdfs" dwwewee,
How to Write php?
I really don't want to write ..
This does not seem to work either.
preg_match("/(token=)(.*?)(;|$)/i","user=asdasd; token=dwwewee; type=assdfs", $matches);foreach ($matches as $m){ echo $m;echo "
";}
(?<=token=).*(?=;)
if (preg_match("/(token=)(.*?)(;|$)/i","user=asdasd; token=dwwewee; type=assdfs", $matches)) { print_r($matches[2]);}
If the matching is successful, the results will be stored in the $ matches array. index 0 is the matching complete string, 1 is your first bracket, 2 is the second bracket, and so on. From your perspective, the value you need appears in the second bracket, so the value $ matches [2]
php
//php5.6 echo explode('=',explode(';',$str)[1])[1];//dwwewee$arr = explode(';',"user=asdasd; token=dwwewee; type=assdfs");$arr2 = explode('=',$arr[1]);echo $arr2[1];//dwwewee