简体   繁体   中英

how to transfer the result from zrange withscore to array in PHP

redis> ZADD myzset 1 "one"
(integer) 1
redis> ZADD myzset 2 "two"
(integer) 1
redis> ZADD myzset 3 "three"
(integer) 1
redis> ZRANGE myzset 0 -1 WITHSCORES
1) "one"
2) "1"
3) "two"
4) "2"
5) "three"
6) "3"

How to transfer this result to key => array in PHP like this:

array(
    "one" => 1,
    "two" => 2,
    "three" => 3
)

Please use some PHP-Redis extension which make all that things for you. As example PHPRedis https://github.com/phpredis/phpredis#zrange

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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