Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Lower Count In An Array

    Basically I have an if statement that goes
    PHP Code:
    if ($cdate3 == $mdate2)
    {

    And I want it to lower the count of the array by 1 whenever they are equal
    PHP Code:
    if ($cdate3 == $mdate2)
    {
    count($arry)--;

    However I'm not sure how to do this. Help is greatly appreciated.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by kochier View Post
    Basically I have an if statement that goes
    PHP Code:
    if ($cdate3 == $mdate2)
    {

    And I want it to lower the count of the array by 1 whenever they are equal
    PHP Code:
    if ($cdate3 == $mdate2)
    {
    count($arry)--;

    However I'm not sure how to do this. Help is greatly appreciated.
    you want de remove a item from array each time the condition is true? first or last or don't matter?
    PHP Code:
    if($cdate3 == $mdate2){
        
    array_pop($arry); // last removed, count decremented
        
    array_shift($arry); // first removed, count will be decremented

    regards

  • Users who have thanked oesxyl for this post:

    kochier (07-31-2008)

  • #3
    Regular Coder
    Join Date
    Jul 2008
    Posts
    136
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Thanks, works perfectly.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •