src/Arrays.php
public static function group_concat($data, $column, $strings = false, $quotes = '\'')
	{
		if (is_string($column))
		{
			$column = array($column);
		}

		/* init the return array */
		$return = array();
		foreach ($column as $col)
		{
			$return[$col] = ($strings ? $quotes : '');
		}

		/* itterate over the data */
		foreach ($data as $row)
		{
			foreach ($column as $col)
			{
				$return[$col] .= $row[$col] . ($strings ? ($quotes . ',' . $quotes) : ',');
			}
		}

		/* clean up the trailing comma */
		foreach ($return as $column => $ret)
		{
			/* if the string is empty, continue on */
			if (($length = strlen($ret)) < 1) continue;

			/* the length to trim off */
			$trim = 1;
			if ($strings)
			{
				$trim = strlen($quotes) + 1;
			}

			$return[$column] = substr($ret, 0, $length - $trim);
		}

		/* return the values */
		return $return;
	}
public static function group_concat($data, $column, $strings = false, $quotes = '\'')
	{
		if (is_string($column))
		{
			$column = array($column);
		}

		/* init the return array */
		$return = array();
		foreach ($column as $col)
		{
			$return[$col] = ($strings ? $quotes : '');
		}

		/* itterate over the data */
		foreach ($data as $row)
		{
			foreach ($column as $col)
			{
				$return[$col] .= $row[$col] . ($strings ? ($quotes . ',' . $quotes) : ',');
			}
		}

		/* clean up the trailing comma */
		foreach ($return as $column => $ret)
		{
			/* if the string is empty, continue on */
			if (($length = strlen($ret)) < 1) continue;

			/* the length to trim off */
			$trim = 1;
			if ($strings)
			{
				$trim = strlen($quotes) + 1;
			}

			$return[$column] = substr($ret, 0, $length - $trim);
		}

		/* return the values */
		return $return;
	}
public static function group_concat ( $ data , $ column , $ strings = false , $ quotes = '\'' ) { if ( is_string ( $ column ) ) { $ column = array ( $ column ) ; } /* init the return array */ $ return = array ( ) ; foreach ( $ column as $ col ) { $ return [ $ col ] = ( $ strings ? $ quotes : '' ) ; } /* itterate over the data */ foreach ( $ data as $ row ) { foreach ( $ column as $ col ) { $ return [ $ col ] .= $ row [ $ col ] . ( $ strings ? ( $ quotes . ',' . $ quotes ) : ',' ) ; } } /* clean up the trailing comma */ foreach ( $ return as $ column => $ ret ) { /* if the string is empty, continue on */ if ( ( $ length = strlen ( $ ret ) ) < 1 ) continue ; /* the length to trim off */ $ trim = 1 ; if ( $ strings ) { $ trim = strlen ( $ quotes ) + 1 ; } $ return [ $ column ] = substr ( $ ret , 0 , $ length - $ trim ) ; } /* return the values */ return $ return ; }
emulate the MySql group concat function for a result set

@param array $data the data array to process
@param string|array $column the column to concat
@param boolean $strings treat the values as strings
@param string $quotes the quotes to use when handeling strings
@return array('column']=>'concated_string',...)
emulate the MySql group concat function for a result set