{{{HTML_BODY_CONTENT}}} NOWDOC; function cartesianProduct($first, $second) { $product = []; foreach ($first as $a) { foreach ($second as $b) { $product[] = [$a, $b]; } } return $product; } function cartesianProductString($first, $second,$separator) { $product = []; foreach ($first as $a) { foreach ($second as $b) { $product[] = $a.$separator.$b; } } return $product; } $list_width = range(0,3048); $list_height = array("net mm", "gross mm"); $product_all = cartesianProductString($list_width,$list_height," "); echo count($product_all); //array_merge(array ...$arrays): array $str_out = ''; $str_out .=""; $str_out .=""; $str_out .= implode(' '.PHP_EOL, array_map( function($product) {return ""; $base_html = str_replace('{{{HTML_BODY_CONTENT}}}', $str_out, $base_html); $filehandle = fopen('Massive_Autocomplete_HTML_Data_List_Test.html', "w") ; fwrite($filehandle, $base_html); fclose($filehandle); ?>