Note that there are some explanatory texts on larger screens.

plurals
  1. POremoving data from array
    primarykey
    data
    text
    <p>I have a problem i need to ignore any array key if it has "lastpost" set to "No Posts"</p> <p>This is the array dump of $sublast:</p> <pre><code> array(3) { [0]=&gt; array(9) { ["forum_category_id"]=&gt; string(1) "3" ["name"]=&gt; string(15) "Sub category #1" ["description"]=&gt; string(39) "This is a short description test.... #2" ["topics"]=&gt; string(1) "0" ["lastpost"]=&gt; string(8) "No Posts" ["lastpostauthor"]=&gt; string(1) " " ["lastposturl"]=&gt; string(88) "http://test.codetrove.com/index.php?route=forum/read&amp;forum_path=3&amp;forum_post_id=" ["posts"]=&gt; int(0) ["href"]=&gt; string(81) "http://test.codetrove.com/index.php?route=forum/forum_category&amp;forum_path=1_3" } [1]=&gt; array(9) { ["forum_category_id"]=&gt; string(1) "7" ["name"]=&gt; string(16) "Test sub Sub cat" ["description"]=&gt; string(0) "" ["topics"]=&gt; string(1) "2" ["lastpost"]=&gt; string(26) "Mon Apr 1, 2013 1:00:42 pm" ["lastpostauthor"]=&gt; string(16) "Justine Smithies" ["lastposturl"]=&gt; string(90) "http://test.codetrove.com/index.php?route=forum/read&amp;forum_path=7&amp;forum_post_id=63" ["posts"]=&gt; int(2) ["href"]=&gt; string(81) "http://test.codetrove.com/index.php?route=forum/forum_category&amp;forum_path=1_7" } [2]=&gt; array(9) { ["forum_category_id"]=&gt; string(1) "9" ["name"]=&gt; string(11) "Test cat #3" ["description"]=&gt; string(20) "Short description #3" ["topics"]=&gt; string(1) "2" ["lastpost"]=&gt; string(26) "Mon Apr 1, 2013 1:00:15 pm" ["lastpostauthor"]=&gt; string(16) "Justine Smithies" ["lastposturl"]=&gt; string(90) "http://test.codetrove.com/index.php?route=forum/read&amp;forum_path=9&amp;forum_post_id=62" ["posts"]=&gt; int(2) ["href"]=&gt; string(81) "http://test.codetrove.com/index.php?route=forum/forum_category&amp;forum_path=1_9" } } </code></pre> <p>Here is the code i am trying to do that only it messes up as it always goes for the top one which is right but i need a way to remove the top entries if the have "lastpost" set to "No Posts" so it get the correct info .</p> <pre><code> &lt;?php $sublast = $forum_category['children']; foreach ($sublast as $key =&gt; $row) { $dates[$key] = $row['lastpost']; } array_multisort($dates, SORT_ASC, $sublast); $lastitem = $sublast[count($sublast) - 1]; var_dump($sublast); ?&gt; </code></pre> <p>This is the dump of $lastitem :</p> <pre><code> array(9) { ["forum_category_id"]=&gt; string(1) "3" ["name"]=&gt; string(15) "Sub category #1" ["description"]=&gt; string(39) "This is a short description test.... #2" ["topics"]=&gt; string(1) "0" ["lastpost"]=&gt; string(8) "No Posts" ["lastpostauthor"]=&gt; string(1) " " ["lastposturl"]=&gt; string(88) "http://test.codetrove.com/index.php?route=forum/read&amp;forum_path=3&amp;forum_post_id=" ["posts"]=&gt; int(0) ["href"]=&gt; string(81) "http://test.codetrove.com/index.php?route=forum/forum_category&amp;forum_path=1_3" } </code></pre> <p>And as you can see it took the "No Posts" when that whole array entry should be removed so it takes array[1] Which is the one i need.</p> <p>Any ideas please ?</p>
    singulars
    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.
 

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