php_novice2007 Posted May 7, 2007 Share Posted May 7, 2007 Hi, I'm trying to use the array_unique function and its not giving me some of my values... So for example, $input = array("4", "4", "3", "4", "3", "5","7","7"); $indiGroup = array_unique($input); for($j=0; $j < count($indiGroup); $j++) { print "<option value=$indiGroup[$j]>$indiGroup[$j]</option>"; } When I put this code in my page, my drop down lists has "4", and then a gap, and then "3", and then a gap.. It seems to be missing every second one. ??? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted May 7, 2007 Share Posted May 7, 2007 print_r() the $indiGroup? Quote Link to comment Share on other sites More sharing options...
warewolfe Posted May 7, 2007 Share Posted May 7, 2007 replace for($j=0; $j < count($indiGroup); $j++) { print "<option value=$indiGroup[$j]>$indiGroup[$j]</option>"; } with foreach($indiGroup as $val){ echo"<option = $val> $val </option>";} Quote Link to comment Share on other sites More sharing options...
php_novice2007 Posted May 7, 2007 Author Share Posted May 7, 2007 Sweet, thanks~! I'm curious... How come the other way didn't work? Quote Link to comment Share on other sites More sharing options...
genericnumber1 Posted May 7, 2007 Share Posted May 7, 2007 I don't believe you can use variables for array indexes inside of double quotes... you probably could have done... print "<option value=" . $indiGroup[$j] . ">" . $indiGroup[$j] . "</option>"; with no problems Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.