Skip to content

Commit 49c7a2d

Browse files
committed
feat: add new tool func: printm
1 parent b4e4d00 commit 49c7a2d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/func.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
if (!function_exists('println')) {
1414
/**
15+
* print multi vars with newline.
16+
*
1517
* @param mixed ...$vars
1618
*
1719
* @return void
@@ -39,6 +41,35 @@ function println(...$vars): void
3941
}
4042
}
4143

44+
if (!function_exists('printm')) {
45+
/**
46+
* print multi vars.
47+
*
48+
* @param mixed ...$vars
49+
*
50+
* @return void
51+
*/
52+
function printm(...$vars): void
53+
{
54+
$eleNum = count($vars);
55+
if ($eleNum === 1) {
56+
echo DataHelper::toString($vars[0]);
57+
return;
58+
}
59+
60+
if ($eleNum === 0) {
61+
return;
62+
}
63+
64+
// eleNum > 1
65+
$ss = [];
66+
foreach ($vars as $var) {
67+
$ss[] = DataHelper::toString($var);
68+
}
69+
echo implode('', $ss);
70+
}
71+
}
72+
4273
if (!function_exists('vdump')) {
4374
/**
4475
* Dump data like var_dump

0 commit comments

Comments
 (0)