# tablepress/3.4/libraries/vendor/PhpSpreadsheet/Calculation/LookupRef/Hstack.php

TablePress – Tables in WordPress made easy, version 3.4. 50 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/LookupRef/Hstack.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/Calculation/LookupRef/Hstack.php
- Modified: 2026-09-30T03:50:46+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Calculation/LookupRef/Hstack.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet\Calculation\LookupRef;

use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Functions;
use TablePress\PhpOffice\PhpSpreadsheet\Calculation\Information\ExcelError;

class Hstack
{
	/**
				 * Excel function HSTACK.
				 *
				 * @return mixed[]|string
				 * @param mixed ...$inputData
				 */
				public static function hstack(...$inputData)
	{
		$maxRow = 0;
		foreach ($inputData as $matrix) {
			if (!is_array($matrix)) {
				$count = 1;
			} else {
				$count = count($matrix);
			}
			$maxRow = max($maxRow, $count);
		}
		/** @var mixed[] $inputData */
		foreach ($inputData as &$matrix) {
			if (!is_array($matrix)) {
				$matrix = [$matrix];
			}
			$rows = count($matrix);
			$reset = reset($matrix);
			$columns = is_array($reset) ? count($reset) : 1;
			while ($maxRow > $rows) {
				$matrix[] = array_pad([], $columns, ExcelError::NA());
				++$rows;
			}
		}

		$transpose = array_map(null, ...$inputData); //* @phpstan-ignore argument.type (inputData is mixed not array)
		$returnMatrix = [];
		foreach ($transpose as $array) {
			$returnMatrix[] = Functions::flattenArray($array);
		}

		return $returnMatrix;
	}
}

```
