holladb Posted November 15, 2007 Share Posted November 15, 2007 Hey guys, im trying to catch duplicate entries in my array. The array is being created with data from the dbase. I have separated the items with a space (tried a comma previously) I tried using the array_unique function to do this manually but failed to see results. Anybody have a solution? while($row = $result->fetch()) { $orderit[] .= array("'".$row['scat01']."' "); } //$owe = join('',$orderit); //$orderit = array_unique($orderit); //print_r ($orderit); //foreach($orderit as $items) { //echo $items; //} $orderit = explode (" ", $orderit); print_r($orderit); Above is where i left off because i am extremely stumped. Somebody help me remove unique arrays and explode them properly? Quote Link to comment Share on other sites More sharing options...
Barand Posted November 15, 2007 Share Posted November 15, 2007 <?php while($row = $result->fetch()) { $orderit[] = $row['scat01']; } $unique = array_unique($orderit); echo '<pre>', print_r($unique, true), '</pre>'; ?> Or you could "SELECT DISTINCT scat01 FROM mytablename" Quote Link to comment Share on other sites More sharing options...
holladb Posted November 15, 2007 Author Share Posted November 15, 2007 Barand that works great thanks! From that i was able to print each variable in true form while($row = $result->fetch()) { $orderit[] = $row['scat01']; } $unique = array_unique($orderit); foreach ($unique as $items) { echo $items.'<br>'; } 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.