I have a multidimensional array that loks lik this:
Array
(
[0] => Array
(
[name] => >chr1:2198584545754_genome_1000+
[score] => 511
[hit] => 50
)
[1] => Array
(
[name] => >chr2:2198581212154_genome_1000+
[score] => 620
[hit] => 80
)
[2] => Array
(
[name] => >chr3:2115151215754_genome_1000+
[score] => 666
[hit] => 90
)
[3] => Array
(
[name] => >chr4:2198584545754_genome_1000+
[score] => 750
[hit] => 50
)
[4] => Array
(
[name] => >chr5:1218455145754_genome_1000+
[score] => 800
[hit] => 100
)
[5] => Array
(
[name] => >chr6:1231354645454_genome_1000+
[score] => 850
[hit] => 110
)
[6] => Array
(
[name] => >chr7:1231213211134_genome_1000+
[score] => 900
[hit] => 120
)
)
I have a foreach loop which will loop through each letter of a random sequence and use the index to give each letter a number value. If the value of ['hit'] matches the index value of the random sequence i want to insert a function.
I cannot figure this out. I think my problem is in callng each value of ['hit'] and comparing with index. Does anyone know how to do this ? thanks
To put DaveRandom's comment into an answer (with minor amends):
foreach ($outerArray as $index => $innerArray)
{
if($innerArray['hit'] === $index)
{
doSomething();
}
}
@DaveRandom - feel free to delete or re-post this as your own answer if I'm posting out of turn here...
foreach ($array as $key) {
if ($key['hit'] == $index)
{
// you function or logic here
}
}