|
|
|
/* F_SearchArr
* Search for $item in $arr.
* Return -1 if nothing, location in $arr if so.
*
* Copyright (C) 1999 David W. Bettis
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
function F_SearchArr($arr, $item)
{
$result = -1;
for ($i = 0; $i < count($arr); $i++) {
if (strcmp($arr[$i], $item) == 0) {
$result = $i;
}
}
return($result);
}
|
|
| Tag content retrieval from websites with preg_match Categories : PHP, Regexps, Arrays, HTML and PHP | | | clearing variables in php3 Categories : Variables, Arrays, PHP | | | Array values from javascript to php Categories : PHP, Java Script, Arrays | | | Display list of files within current and subdirectories (recursively) showing
each file as an anchored link and each directory as a category header. Categories : Filesystem, Directories, Arrays, PHP | | | Weighted Random - Random Scripts usually chose one out of each item, and each item have an equal chance to be chosen. But what if you want an item to be chosed more frequently than other? Categories : PHP, Math., Arrays | | | Dump the contents of a PHP variable in html format with a recursive list of subfolders and files from a given root directory.
Categories : PHP, Directories, Variables, Arrays | | | Array Insertion Categories : PHP, PHP Classes, Arrays | | | PHP Script to find url links in a page Categories : PHP, URLs, Regexps, Arrays | | | Check for functional file links (broken Files)
Categories : PHP, Data Validation, FTP, Regexps, Arrays | | | This gets the http response headers for a given url and returns them in an assoc array. i.e. to test if a url exists: $array = get_http_headers($url); if($array[result]=200) { } Categories : HTTP, Arrays, PHP | | | Beginners Array Functions Categories : PHP, Beginner Guides, Arrays | | | How to pass an array from one PHP Script to another via an HTML form Categories : PHP, HTML and PHP, Arrays | | | How to load a query result into a PHP Array Categories : PHP, Databases, Arrays, MySQL | | | dynamic table columns Categories : PHP, HTML and PHP, Arrays, Databases, MySQL | | | Print out array key => value in colored HTML Categories : PHP, Arrays, HTML and PHP | |
| | | | Fredrik Kjell wrote : 294
Should U worry about creating some nice code instead
of protecting already know knowledge?
| | | | Franz Prilmeier wrote : 397
Wouldn´t it be better to return true, if item has been found
in the array? That way, the search would perform faster.
| | | | Faro Rasyid wrote :613
this code is quite useful for php3 user...
and Prilmeier Franz is right, it`s better to
return a boolean value
| |
|
|
|