Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $list = array();
- // hash looks like c:order(contains the data) and l:replyID(has the c:order for each reply so I can remove replies)
- foreach($redis->hGetAll("reply_post:".$id) as $l => $r){
- if(substr($l,0,1) === "l"){continue;} // $l looks like l:203 | c:1 . And if $l has l in the first character then ignore
- $list[intval(substr($l,2))] = $r; // $l is now c:x and I want x to get the right order and c:x contains reply that which is $r
- }
- ksort($list,SORT_NUMERIC); // sort the array by numeric so the replies are in right order
- foreach($list as $r){
- $c[$c_id]["post_replies"][] = $r;
- }
- ------------------------------------------------------------------------
- Or if I would use 2 redis hashes then it would look like this
- foreach($redis->hGetAll("reply_post_list:".$id) as $l => $r){
- if($redis->hexists("reply_post".$id,"c:".$r)){
- $c[$c_id]["post_replies"][] = $redis->hget("reply_post".$id,"c:".$r);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement