public function maybeImplode( array $attributes, $implode = true )
	{
		if( !$implode || $implode !== 'implode' ) {
			return $attributes;
		}
		$results = [];
		foreach( $attributes as $key => $value ) {
			// if data attributes, use single quotes in case of json encoded values
			$quotes = false !== stripos( $key, 'data-' ) ? "'" : '"';
			if( is_array( $value )) {
				$value = json_encode( $value );
				$quotes = "'";
			}
			$results[] = is_string( $key )
				? sprintf( '%1$s=%3$s%2$s%3$s', $key, $value, $quotes )
				: $value;
		}
		return implode( ' ', $results );
	}
public function maybeImplode( array $attributes, $implode = true )
	{
		if( !$implode || $implode !== 'implode' ) {
			return $attributes;
		}
		$results = [];
		foreach( $attributes as $key => $value ) {
			// if data attributes, use single quotes in case of json encoded values
			$quotes = false !== stripos( $key, 'data-' ) ? "'" : '"';
			if( is_array( $value )) {
				$value = json_encode( $value );
				$quotes = "'";
			}
			$results[] = is_string( $key )
				? sprintf( '%1$s=%3$s%2$s%3$s', $key, $value, $quotes )
				: $value;
		}
		return implode( ' ', $results );
	}
public function maybeImplode ( array $ attributes , $ implode = true ) { if ( ! $ implode || $ implode !== 'implode' ) { return $ attributes ; } $ results = [ ] ; foreach ( $ attributes as $ key => $ value ) { // if data attributes, use single quotes in case of json encoded values $ quotes = false !== stripos ( $ key , 'data-' ) ? "'" : '"' ; if ( is_array ( $ value ) ) { $ value = json_encode ( $ value ) ; $ quotes = "'" ; } $ results [ ] = is_string ( $ key ) ? sprintf ( '%1$s=%3$s%2$s%3$s' , $ key , $ value , $ quotes ) : $ value ; } return implode ( ' ' , $ results ) ; }
Possibly implode attributes into a string

@param bool|string $implode

@return array|string
Possibly implode attributes into a string