Announcement

Collapse
No announcement yet.

How to test every element of an array

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mark Hensler
    replied
    You might want to note that in_array() returns a boolean value. If you want the key where the element was found, you'll need to use array_search().

    Leave a comment:


  • jrwap
    replied
    A+ service once again. I'll give it a try in a bit.

    Thanks again,

    -JRW

    Leave a comment:


  • Mark Hensler
    replied
    bool in_array ( mixed needle, array haystack [, bool strict])

    PHP Docs: in_array()

    How's that for service?

    Leave a comment:


  • jrwap
    started a topic How to test every element of an array

    How to test every element of an array

    I have an array of numbers and I have another number which I want to test to see if it is in the array. How do I do this?

    So, if I have the numbers 4, 5, and 6 in the array called $list and I have a variable called $test which contains the number 5. How do I test the contents of the variable against every item in the array.

    Thanks ... ummm probably to my hero MAX!!

    -JRW
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X