fork(1) download
  1. <?php
  2. $row_values = [
  3. 'POS RETAIL|INVENTORY STANDARD',
  4. 'POS RETAIL',
  5. 'POS RETAIL|',
  6. 'INVENTORY STANDARD'
  7. ];
  8.  
  9. $items = [];
  10.  
  11. //get all items from database and explode the concat values.
  12. foreach ($row_values as $row) {
  13. $items = array_merge($items, explode('|', $row));
  14. }
  15.  
  16. //get only the distinct items.
  17. $items = array_unique($items);
  18.  
  19. //remove the emtpy items.
  20. $items = array_filter($items);
  21.  
  22. //initialize the list.
  23. $list = '<option value="">SELECT SOFTWARE / HARDWARE</option>';
  24.  
  25. //create the list of unique items.
  26. foreach ($items as $item) {
  27. $list .= "<option value='$item'>$item</option>";
  28. }
  29.  
  30. var_dump($list);
Success #stdin #stdout 0.01s 24012KB
stdin
Standard input is empty
stdout
string(160) "<option value="">SELECT SOFTWARE / HARDWARE</option><option value='POS RETAIL'>POS RETAIL</option><option value='INVENTORY STANDARD'>INVENTORY STANDARD</option>"