[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 311
  • Last Modified:

PHP find the index of an array element (long day)

Hi,

It's been a long day, can someone put me out of my mysery:

I have a multi-dimentional array, (below) and I need to get the index sequence number of a specific element.

For example, I am looking for Household '15' so I want the result to be 12.

brain ache.  top points.

Array
(
    [HOUSEHOLD] => Array
        (
            [0] => 2
            [1] => 3
            [2] => 9
            [3] => 20
            [4] =>
            [5] =>
            [6] =>
            [7] => 5
            [8] => 8
            [9] => 7
            [10] => 6
            [11] => 19
            [12] => 15
            [13] => 10
            [14] => 18
            [15] => 1
            [16] => 17
            [17] => 16
        )

    [NAME] => Array
        (
            [0] => SJ of Eastbourne
            [1] => New Player
            [2] => New Player
            [3] => WB of London
            [4] => ...
            [5] =>
            [6] =>
            [7] => New Player
            [8] => New Player
            [9] => SJ of Eastbourne
            [10] => New Player
            [11] => SJ of Eastbourne
            [12] => WB of London
            [13] => New Player
            [14] => SJ of Eastbourne
            [15] => New Player
            [16] => SJ of Eastbourne
            [17] => SJ of Eastbourne
        )
0
CrisThompsonUK
Asked:
CrisThompsonUK
  • 2
1 Solution
 
gr8gonzoConsultantCommented:
http://php.net/manual/en/function.array-search.php

$key = array_search("15",$arr["HOUSEHOLD"]);
0
 
CrisThompsonUKAuthor Commented:
Thanks Gonzo,

Will check this out  tomorro

Cris.
0
 
CrisThompsonUKAuthor Commented:
Thanks Gonzo.

That's exactly what I tried, and convinced myself that it wasn't working!!!

Like I said - long day!!
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now