Posted By

iloveitaly on 08/31/09


Tagged

php element array String key field associative item implode


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Implode On Array Item Key


 / Published in: PHP
 

  1. function implode_on_key($array, $key, $sep, $prefix = '') {
  2. $string = '';
  3.  
  4. if(empty($array)) return '';
  5.  
  6. foreach($array as $element) {
  7. $string .= $prefix.$element[$key].$sep;
  8. }
  9.  
  10. return substr($string, 0, -strlen($sep));
  11. }

Report this snippet  

You need to login to post a comment.