Jump to content

Recommended Posts

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 ?

 

[/background][/size][/font][/color]

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
)

)

)

)

) 
[color=#000000][font=verdana][size=1][background=rgb(252, 252, 252)]
Edited by yazzou
Link to comment
https://forums.phpfreaks.com/topic/269387-verify-if-a-key-has-a-value-in-subarray/
Share on other sites

Set a flag variable to false, then use a foreach loop to go over each array element and check it's ['tid'] element to see if it matches. If it does, set the flag variable to true. After the loop, check if the flag variable is true or false.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.