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 2010
    Location
    Sheffield
    Posts
    824
    Thanks
    93
    Thanked 18 Times in 18 Posts

    If is in a multidimentional array

    I have an array formed like

    $requestedDates[$i]['dayNum']

    which contains the day number of whatever dates are in another array (day number e.g 1 through to 7 (mon to sun))

    I need to search through and find out how many 6's and 7's are in, what would be the best way of doing it? I can only think of using foreach loops but surely theres a better way than that?

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    foreach() is the way to go if you are starting with a multidimensional array. If it was a single dimension you could use array_count_values(). You still could really, if you make an array of the values first.

  • #3
    Regular Coder
    Join Date
    Jul 2010
    Location
    Sheffield
    Posts
    824
    Thanks
    93
    Thanked 18 Times in 18 Posts
    Okay, thanks, i didnt know if there was a better way or not.


  •  

    Posting Permissions

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