php - removing data from array -
i have problem need ignore array key if has "lastpost" set "no posts"
this array dump of $sublast:
array(3) { [0]=> array(9) { ["forum_category_id"]=> string(1) "3" ["name"]=> string(15) "sub category #1" ["description"]=> string(39) "this 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" } }
here code trying messes goes top 1 right need way remove top entries if have "lastpost" set "no posts" correct info .
<?php $sublast = $forum_category['children']; foreach ($sublast $key => $row) { $dates[$key] = $row['lastpost']; } array_multisort($dates, sort_asc, $sublast); $lastitem = $sublast[count($sublast) - 1]; var_dump($sublast); ?>
this dump of $lastitem :
array(9) { ["forum_category_id"]=> string(1) "3" ["name"]=> string(15) "sub category #1" ["description"]=> string(39) "this 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" }
and can see took "no posts" when whole array entry should removed takes array[1] 1 need.
any ideas please ?
unset need.
unset($array)
Comments
Post a Comment