What is the equivalent of Python string.format in PHP

1 Answer

0 votes
$n = 2345;
$f = 74.901;
$s = "php";

echo sprintf("%d %.3f %s", $n, $f, $s);


  
/*
run:
  
2345 74.901 php
  
*/

 



answered Feb 7, 2024 by avibootz

Related questions

1 answer 246 views
1 answer 294 views
294 views asked Aug 7, 2021 by avibootz
1 answer 257 views
257 views asked Aug 7, 2021 by avibootz
1 answer 275 views
275 views asked Aug 7, 2021 by avibootz
1 answer 307 views
307 views asked Aug 7, 2021 by avibootz
1 answer 314 views
1 answer 234 views
234 views asked Aug 9, 2023 by avibootz
...