The function below facilitates the process of converting an array to a string. Very useful for building SQL insert queries with arrays of data.
<?php
function array2str($array, $pre = '', $pad = '', $sep = ', ')
{
$str = '';
if(is_array($array)) {
if(count($array)) {
foreach($array as $v) {
$str .= $pre.$v.$pad.$sep;
}
$str = substr($str, 0, -strlen($sep));
}
} else {
$str .= $pre.$array.$pad;
}
return $str;
}
?>
Related posts:
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.