有没有办法在PHP中获得此功能? 我希望能够选择阵列和它应该读出的位置。这只是示例代码。
<?php
$array[] = "Tim";
$array[] = "Harry";
$arrayb[] = "as";
$arrayb[] = "bla";
$arrayb[] = "zta";
echo printf("Hello %0[0]$s! I want %1[0]$s ti be %0[1]$s and %1[1]$s, %1[2]$s", $array, $arrayb);
#OUTPUT: Hello Tim! I want as to be Harry and bla, zta
答案 0 :(得分:3)
查看http://php.net/manual/en/function.vsprintf.php#87031 - 不同的语法,但目标相同。
答案 1 :(得分:3)
vprintf("Hello %1$s! I want %3$s t0 be %2$s and %4$s, %5$s", array_merge($array,$arrayb));