The Identification Number and Password fields need to be filled in. Moreover, you cannot send messages devoid of contents Adding further data is not allowed because this topic has been closed Print You provided no password: you have to write it in the textfield beside the command delete for the topic you want to delete Are you sure you want to delete this comment? You did not cast a vote. You need to cast a vote by selecting a radio button. Impossible to proceed Provide the project number Insufficient form parameters: you forgot to fill in some field/s
 
member picmember pic
 
Snippets of A
 
info Below you can find the text of the snippet you want to read, and the list of the other snippets by this author if available.
What are snippets?
Share on MySpace

Php Search And Find Item In Arrays: Detect Presence In Any Or All Input Arrays

Snippet: Identification Number »   Snippet: Inclusion syntax »
Visitors: 9,944 Tagged by its author as: Programming Php Characters (in origin): 2,648 (pages: ~ 1)
Author: Em@il Permalink Cast your vote for this topic Printable version
OBJECTIVE: find whether a given value is present at least once in any of the input arrays.  
function anyArrayItem($arrayOrArrayOfArrays=array(), $item=''){
$firstRun=array_search($item, $arrayOrArrayOfArrays, true);
if($firstRun!==false){return $firstRun;};//any
foreach($arrayOrArrayOfArrays as $arr){
	if( is_array($arr) && (($aSearch=array_search($item, $arr, true))!==false) ){return $aSearch;};
}
return false;
}
Remove colors  
INPUTS: an array, or an array of arrays if you need to perform the search on a set of arrays.  
 
RETURNS: boolean false if the item does not meet the conditions, or a Number representing the index of the first item instance found.  
 
CAVEATS: if the searched item is present more than once, only the index of the first found instance is returned; moreover, if the passed first argument is an array of arrays, such returned number does not reveal in which of the nested array the first instance was found.  
 
The search requires equivalence with the given searched item value and with its data type too: to override this (not recommended) remove the third parameter (and its leading comma) from the function array_search wherever it appears in the code.  
Unfortunately, the searches are all case sensitive.  
OBJECTIVE: find whether a given value is present in all of the input arrays.  
function allArraysItem($arrayOrArrayOfArrays=array(), $item=''){
$firstRun=array_search($item, $arrayOrArrayOfArrays, true);
if($firstRun===false){return false;};//all
foreach($arrayOrArrayOfArrays as $arr){
	if( is_array($arr) && array_search($item, $arr, true)===false ){return false;};
}
return true;
}
Remove colors  
INPUTS: an array, or an array of arrays if you need to perform the search on a set of arrays.  
 
RETURNS: boolean false if the item does not meet the conditions, or boolean true.  
 
CAVEATS: the search requires equivalence with the given searched item value and with its data type too: to override this (not recommended) remove the third parameter (and its leading comma) from the function array_search wherever it appears in the code.  
Unfortunately the searches are all case sensitive.  
 
A note: this routine is conceptually different from Php To Find Identical Items Present In All The Input Arrays: Intersect Arrays insofar as in the latter the item(s) to be found in all the arrays are not passed as a given input to look for, but are investigated and drawn from the input arrays.
Printable version To exclude hyperlinks from the print, check the checkbox »
Rss

Cast your vote for this topic

To perform this operation it is not necessary to be Full Poster members.
«Negative Positive»
Click here to save your vote (Current average: 0.00, Voters: 0)
Are you the author of this topic and do you want to append quickly more text? click here
Other topics
This subscriber has a blog too: Read the blog: 57 Shoutbox: 103 reviews: 153
Visitors: 9,944
Overall visits to all the topics: 4,963,524
Daily average (Calculated from the website subscription day): 2,060.41
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Php
Current order: by category: Epistles Letters and Advice
Other categories available for this author (Limited data report: 100):
Advice: Martial Arts and Self Defense(4), Books(236), Critical Reviews and Essays(4), Dictionaries(1), Emergency Care(4), Epistles Letters and Advice(5), Fantasy Epics and Fables(1), History and Documents(5), Humor and Jokes(2), Methematics(2), Music and Lyrics(6), News Digests and Press Reviews(1), Novels Poetry and Stories(3), Philosophy Reviews(7), Poetry(1), Programming(4), Programming Ajax(2), Programming Javascript(82), Programming Php(52), Psychology(1), Quotes(1), Religion Esoterica and Spirituality(12), Scientifical Reviews(4), Self Improvement(1), Sport Activities and Apparels(2), Tarots(1)
Showing topics: 1, 10
Available total: 448
View only a list of the snippets by this author: click here.
Other topics available for this author: click on any title below to view the complete item:
Everyday's De Profundis Identification Number: 379 Visitors: 14,041 L' Unica Cosa Che Conta E' Lo Yoga Identification Number: 376 Visitors: 15,659 A Reader Writes: A Message For Nick Lane About: "Power, Sex, Suicide". Identification Number: 282 Visitors: 12,606 Aristocracy And Populism: Robert Kiyosaki's Rich Dad Poor Dad Paradigm Identification Number: 226 Visitors: 13,698 Letter For A Daugther Who Has A Problem With Her Parents And Mother Identification Number: 188 Visitors: 15,868
External services
This page of this subscriber uses external services: Hide