Note that there are some explanatory texts on larger screens.

plurals
  1. POSelecting specific keys from a PHP array and then comparing them
    primarykey
    data
    text
    <p>Any help would be greatly appreciated with this.</p> <p>Essentially what I am trying to do is, for each "ticketX" array, select the first response (by date) and then the first response from the helpdesk. So with the example below I would expect the following to be returned:</p> <p><strong>Ticket 1</strong></p> <p>Key "2" and date "2013-11-22 16:35:51"<br> Key "1" and date "2013-11-22 16:51:15"</p> <p><strong>Ticket 2</strong></p> <p>Key "5" and date "2013-11-22 14:41:27"<br> Key "3" and date "2013-11-22 15:47:02"</p> <p>I guess the next logical thing would be to put these results into another separate array which I can then compare? The ultimate goal here is to calculate the response time of the helpdesk, from the customer's first post, to the reply of the helpdesk.</p> <p>I'm not sure how to even approach the issue, so I'm pretty stuck. I could probably hash something together, but I would much rather seek guidance first!</p> <p>At the moment I just have this:</p> <pre><code>foreach($tickets AS $key =&gt; $value) { if(count($value) &gt; 1) { foreach($value AS $value2) { echo = $value2['created']; } } } </code></pre> <p>Here is an example of the array:</p> <pre><code>Array ( [ticket1] =&gt; Array ( [0] =&gt; Array ( [created] =&gt; 2013-11-22 17:03:31 [author] =&gt; 1 ) [1] =&gt; Array ( [created] =&gt; 2013-11-22 16:51:15 [author] =&gt; helpdesk ) [2] =&gt; Array ( [created] =&gt; 2013-11-22 16:35:51 [author] =&gt; 1 ) ) [ticket2] =&gt; Array ( [0] =&gt; Array ( [created] =&gt; 2013-11-22 16:48:17 [author] =&gt; helpdesk ) [1] =&gt; Array ( [created] =&gt; 2013-11-22 16:20:18 [author] =&gt; 1 ) [2] =&gt; Array ( [created] =&gt; 2013-11-22 15:49:16 [author] =&gt; helpdesk ) [3] =&gt; Array ( [created] =&gt; 2013-11-22 15:47:02 [author] =&gt; helpdesk ) [4] =&gt; Array ( [created] =&gt; 2013-11-22 15:44:57 [author] =&gt; 2 ) [5] =&gt; Array ( [created] =&gt; 2013-11-22 14:41:27 [author] =&gt; 1 ) ) ) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload