Jump to content


Photo

Search in arrays?


  • Please log in to reply
3 replies to this topic

#1 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 22 October 2006 - 01:54 PM

I have the following problem i have 5 checkboxes with the name asd[]
when someone is adding an article he is cheking for example 3 checkboxes with values 2,4,5

Then i have a search page.A user selects the chekboxes but in that order:

5,2,4

Will php create the same array with the values 2,4,5 ordering them in alph. order or it will create an array like 5,2,4.And if the second how can i make a search,because the values are the same but as they are stored in the row like 2,4,5 and i search for 5,2,4 i wont get anything.

Please help :)

#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 22 October 2006 - 02:28 PM

I dont know, but you can just use the function sort() on both arrays before comparing :)

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 22 October 2006 - 03:19 PM

example:
<?php

$asd = array(9,15,5,3,7,1);
sort($asd);
reset($asd);
$new_asd = implode($asd,",");
echo $new_asd; // 1,3,5,7,9,15

?>


#4 feri_soft

feri_soft
  • Members
  • PipPipPip
  • Advanced Member
  • 147 posts

Posted 22 October 2006 - 06:14 PM

Thanks! 10x




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users