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:

  1. PHP Parallel Web Scraper
  2. PHP Simple Profiling Class
  3. PHP Named Parameters
  4. PHP fast, large (megabyte), data transfer between sessions
  5. Convert HTML to PDF in PHP (libwkhtmltox extension)