I played with this, and if you are struggling with this, the following example will surely help (after the redis.io examples ):
$predis->zadd( 'myset', [ "one" => 1, "uno" => 1, "two" => 2, "three" => 3 ] )
this will result in the same sorted set as the redis example:
ZADD myzset 1 "one"
ZADD myzset 1 "uno"
ZADD myzset 2 "two" 3 "three"
the tricky part of this, if you want to do it on one line in Redis, you first give ratings, for example:
ZADD myzset 1 "one" 1 "uno" 2 "two" 3 "three"
in Predis, this will work too:
$predis->zadd( 'myset', 1, "one", 1, "uno", 2, "two", 3, "three" );
source
share