Searching Numbers in Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Dunnzie
Forum Newbie
Posts: 1
Joined: Wed Feb 22, 2006 1:23 pm

Searching Numbers in Array

Post by Dunnzie »

For my website, http://www.gofanboy.com , I am working on allowing the user to view all bids they have placed under a section called "my posts". I do this by storing the id of the item the user bid on under the users current bid field. The current bid field consists of numbers seperated by spaces ex(63 21 76). I need to know the best way after exploding the string to search for each item id seperately. Any thoughts would be appreciated.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

foreach($itemID AS $item){
   if(in_array($item,$yourExlplodedArray)){
      // item is in array, so do what you wish with it 
   }
}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply