WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Array search function
Categories : Arrays, PHP Update Picture
David Bettis
Date : Sep 24th 1999
Grade : 3 of 5 (graded 8 times)
Viewed : 36024
File : No file for this code example.
Images : No Images for this code example.
Search : More code by David Bettis
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

/* 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);
}



A simple bubblesort that takes 2 arrays as argument.The first one is the actual data used for sorting, the second is data that will "tag along" with the first array, for instance a descriptive text about the data in the first array.
Categories : Algorithms, Arrays, PHP, Complete Programs
Parsing html tags with php. Get an array from this function
Categories : PHP, HTML and PHP, Arrays, Tag Extractors
Selecting a random line from a text file
Categories : PHP, Filesystem, Arrays, Beginner Guides
clearing variables in php3
Categories : Variables, Arrays, PHP
How to Get a character array from a string
Categories : PHP, Strings, Arrays
navbar.php3 - Dynamic hyperlinked navigation bars
Categories : HTML and PHP, Arrays, PHP, Complete Programs
PHP Random rss feeds - selects 49 random feeds from an unlimited list and displays them on your website. It's Ideal for those moments when you got 5 minutes and dont know which one of your feeds to read.
Categories : PHP, Rich Site Summary (RSS), Arrays
Array values from javascript to php
Categories : PHP, Java Script, Arrays
Get TemplateMonster data
Categories : Arrays, Ecommerce, PHP, Strings
Print out array key => value in colored HTML
Categories : PHP, Arrays, HTML and PHP
The meaning of your name
Categories : PHP, Arrays, Misc
PHP Array to Javascript Object
Categories : PHP, Arrays, Java Script
Form Submission Using Array's
Categories : PHP, HTML and PHP, Beginner Guides, Arrays
Parse string to find sub-string between two arbitrary strings
Categories : PHP, Strings, HTML and PHP, 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
 Fredrik Kjell wrote : 294
Should U worry about creating some nice code instead 
of protecting already know knowledge?
 
 Franz Prilmeier wrote : 397
Wouldnt 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