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: 10,016 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: 10,016
Overall visits to all the topics: 4,983,601
Daily average (Calculated from the website subscription day): 2,065.31
Optional sorting commands:
Normal order: click here
Order by amount of visits: click here
Order by category: Programming Php
Current order: by category: Programming Php
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:
Php Date: Full Disaggregated Date Difference Accounting Timezones And Daylight Identification Number: 453 Visitors: 8,760 PHP Date: Disaggregated Date Difference As Interlapsed Days Hours Minutes Second Identification Number: 452 Visitors: 8,912 PHP Pass To Javascript Php Array Associative Array Or Matrix Identification Number: 419 Visitors: 10,878 PHP: Retrounpad A Matrix Array Table: Remove Shared Empty Columns Identification Number: 412 Visitors: 9,320 PHP: Strip Tags But Register Offsets. Replace Text Without Affecting Html Tags. Identification Number: 407 Visitors: 9,393 Php Check Whether A Web Site Or A Web Resource Exists/Responds Identification Number: 391 Visitors: 12,409 Php: Get Value Of Specific Html Meta Tag Identification Number: 389 Visitors: 17,850 Php Given Url Fetch Youtube Video Codes Embed/Include Video In Other Webpage Identification Number: 388 Visitors: 18,318 Php Find Length Of Texts Or Longest Within Instances Of A Given Html Tag Type Identification Number: 387 Visitors: 14,707 PHP: Match Each Array Item Once With All The Other Array Items Identification Number: 370 Visitors: 14,344
External services
This page of this subscriber uses external services: Hide