Php 从阵列中删除数据

Php 从阵列中删除数据,php,arrays,Php,Arrays,我有一个问题,我需要忽略任何数组键,如果它的“lastpost”设置为“No Posts” 这是$sublast的数组转储: array(3) { [0]=> array(9) { ["forum_category_id"]=> string(1) "3" ["name"]=> string(15) "Sub category #1" ["description"]=> string(39) "This is a short description test..

我有一个问题,我需要忽略任何数组键,如果它的“lastpost”设置为“No Posts”

这是$sublast的数组转储:

    array(3) { [0]=> array(9) { ["forum_category_id"]=> string(1) "3" ["name"]=>  string(15) "Sub category #1" ["description"]=> string(39) "This is a short description test.... #2" ["topics"]=> string(1) "0" ["lastpost"]=> string(8) "No Posts" ["lastpostauthor"]=> string(1) " " ["lastposturl"]=> string(88) "http://test.codetrove.com/index.php?route=forum/read&forum_path=3&forum_post_id=" ["posts"]=> int(0) ["href"]=> string(81) "http://test.codetrove.com/index.php?route=forum/forum_category&forum_path=1_3" } [1]=> array(9) { ["forum_category_id"]=> string(1) "7" ["name"]=> string(16) "Test sub Sub cat" ["description"]=> string(0) "" ["topics"]=> string(1) "2" ["lastpost"]=> string(26) "Mon Apr 1, 2013 1:00:42 pm" ["lastpostauthor"]=> string(16) "Justine Smithies" ["lastposturl"]=> string(90) "http://test.codetrove.com/index.php?route=forum/read&forum_path=7&forum_post_id=63" ["posts"]=> int(2) ["href"]=> string(81) "http://test.codetrove.com/index.php?route=forum/forum_category&forum_path=1_7" } [2]=> array(9) { ["forum_category_id"]=> string(1) "9" ["name"]=> string(11) "Test cat #3" ["description"]=> string(20) "Short description #3" ["topics"]=> string(1) "2" ["lastpost"]=> string(26) "Mon Apr 1, 2013 1:00:15 pm" ["lastpostauthor"]=> string(16) "Justine Smithies" ["lastposturl"]=> string(90) "http://test.codetrove.com/index.php?route=forum/read&forum_path=9&forum_post_id=62" ["posts"]=> int(2) ["href"]=> string(81) "http://test.codetrove.com/index.php?route=forum/forum_category&forum_path=1_9" } } 
这是我试图做的代码,只是它搞砸了,因为它总是去顶部的一个是正确的,但我需要一种方法来删除顶部条目,如果有“lastpost”设置为“No Posts”,所以它得到正确的信息

                        <?php
                        $sublast = $forum_category['children'];
                        foreach ($sublast as $key => $row) {
                        $dates[$key]  = $row['lastpost']; 
                        }
                        array_multisort($dates, SORT_ASC, $sublast);
                        $lastitem = $sublast[count($sublast) - 1];
                         var_dump($sublast); 
                        ?>
正如您所看到的,当整个数组条目应该被删除时,它使用了“No Posts”,因此它使用了我需要的数组[1]


有什么想法吗?

使用php中的函数删除元素

取消设置即可满足您的需要

unset($array)
unset($array)