note 103825 deleted from function.implode by danbrown

From: Date: Thu, 05 May 2011 15:04:03 +0000
Subject: note 103825 deleted from function.implode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-179457@lists.php.net to get a copy of this message
Note Submitter: Patrick van der Leer at t maatwebsite dot nl ---- Wrote my own function to format a string correctly in human language, in my case dutch. I know it has been written as shown in comments below but you can't have too much ways to accomplish your goals. <?php function formatArr2Str($arr, $glue=', ', $fglue=' en ') { if(!empty($arr) && is_array($arr)) { $return=''; $j=(count($arr)-1); for($i=0;$i<=$j;$i++){ if($i==($j-1)){ if(!empty($fglue)){ $return .= $arr[$i].$fglue; } else { $return .= $arr[$i].$glue; } }elseif($i<=($j-2)){ $return .= $arr[$i].$glue; } else { $return .= $arr[$i]; } } return $return; } else { return false; } } ?>

« previous php.notes (#179457) next »