Page 1 of 1

Searching Numbers in Array

Posted: Wed Feb 22, 2006 1:28 pm
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.

Posted: Wed Feb 22, 2006 1:34 pm
by hawleyjr

Posted: Wed Feb 22, 2006 10:08 pm
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 
   }
}