PHP creating a multidimensional array of message threads from a multidimensional array (IMAP)

前端 未结 4 1063
刺人心
刺人心 2021-01-19 03:46

My question is the following:

If you look below you\'ll see there is a datastructure with message ids and then the final datastructure containing the message detail

4条回答
  •  伪装坚强ぢ
    2021-01-19 04:09

    I don't have access to PHP right now, to test, but I believe what you're trying to do is something like

    foreach($emails as $email) {
        foreach($threads as $root => $messages) {
            foreach($messages as $index =>$message_id){
                if($message_id == $email->msgno){
                     $threads[$root][$index] = $email;
                }
            }
        }
    }
    

    That being said, even if this works, there is probably a more efficient way to approach this than with three nested loops. What is your reason for needing to store the output in this format?

提交回复
热议问题