Welcome to WebmasterWorld Guest from 54.163.168.15

Forum Moderators: coopster & jatar k

Verify if a key has a value in subarray

   
2:46 pm on Oct 12, 2012 (gmt 0)

5+ Year Member



Hello

I have the following array and i would like to make a function where i can check if one of the [tid] values is equal to 2 or not. How can do that in such multidimensional array ?
Array
(
[0] => Array
(
[tid] => 2
[taxonomy_term] => stdClass Object
(
[tid] => 2
[vid] => 2
[name] => languedoc
[description] =>
[format] =>
[weight] => 0
[vocabulary_machine_name] => mots_cles
[rdf_mapping] => Array
(
[rdftype] => Array
(
[0] => skos:Concept
)

[name] => Array
(
[predicates] => Array
(
[0] => rdfs:label
[1] => skos:prefLabel
)

)

[description] => Array
(
[predicates] => Array
(
[0] => skos:definition
)

)

[vid] => Array
(
[predicates] => Array
(
[0] => skos:inScheme
)

[type] => rel
)

[parent] => Array
(
[predicates] => Array
(
[0] => skos:broader
)

[type] => rel
)

)

)

)

[1] => Array
(
[tid] => 3
[taxonomy_term] => stdClass Object
(
[tid] => 3
[vid] => 2
[name] => marseille
[description] =>
[format] =>
[weight] => 0
[vocabulary_machine_name] => mots_cles
[rdf_mapping] => Array
(
[rdftype] => Array
(
[0] => skos:Concept
)

[name] => Array
(
[predicates] => Array
(
[0] => rdfs:label
[1] => skos:prefLabel
)

)

[description] => Array
(
[predicates] => Array
(
[0] => skos:definition
)

)

[vid] => Array
(
[predicates] => Array
(
[0] => skos:inScheme
)

[type] => rel
)

[parent] => Array
(
[predicates] => Array
(
[0] => skos:broader
)

[type] => rel
)

)

)

)

)
7:31 pm on Oct 14, 2012 (gmt 0)

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member



array_walk might fit the bill:
[php.net...]
11:47 am on Oct 17, 2012 (gmt 0)



If you are trying to grab data from inner arrays, try to use basic approach - recursion (function calls itself).
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month