Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: None  |  size: 0.54 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. how to separate array with commas?
  2. <?php
  3.     if ( is_array($_categories) ) {
  4.         foreach ($_categories as $key => $value) {
  5.             $out = array();
  6.             array_push($out, $value);
  7.             echo implode(', ', $out);
  8.         }
  9.     }
  10.     else {
  11.         echo '<li>There are no saved values yet.</li>';
  12.     }
  13. ?>
  14.        
  15. echo implode(', ', $_categories);
  16.        
  17. $out = array();   //putting outside of the loop
  18. foreach ($_categories as $key => $value) {
  19.     array_push($out, $value);
  20. }    
  21. echo implode(', ', $out);   //putting outside of the loop